/* ===========================
   Feel Free Rentals - Main CSS
   Modern & Professional Design
   =========================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Colors - Professional Palette */
    --primary: #2563eb;
    --primary-light: #3b82f6;
    --primary-dark: #1d4ed8;
    --secondary: #64748b;
    --secondary-light: #94a3b8;
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --info: #0ea5e9;

    /* Backgrounds */
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --bg-light: #475569;

    /* Text */
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-tertiary: #94a3b8;

    /* Borders */
    --border: #334155;
    --border-light: #475569;

    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;

    /* Typography */
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;

    /* Border Radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 200ms ease;
    --transition-slow: 300ms ease;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-family);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    overflow: hidden;
}

/* ==================== APP LAYOUT ==================== */

#app {
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.main-app {
    display: flex;
    width: 100%;
    height: 100%;
    gap: 0;
    background: var(--bg-primary);
}

/* ==================== SIDEBAR ==================== */

.sidebar {
    width: 280px;
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-tertiary) 100%);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: var(--space-lg);
    gap: var(--space-xl);
    overflow-y: auto;
    position: relative;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

.sidebar-logo {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: var(--font-size-xl);
    color: white;
    box-shadow: var(--shadow-md);
}

.sidebar-title {
    font-size: var(--font-size-xl);
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

/* ==================== CHANNEL NAVIGATION ==================== */

.channel-nav {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    flex: 1;
}

.channel-btn {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-lg);
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: var(--font-size-sm);
    font-weight: 500;
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
}

.channel-btn::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: 3px;
    height: 100%;
    background: var(--primary);
    transform: scaleY(0);
    transition: transform var(--transition-base);
}

.channel-btn:hover {
    background: rgba(37, 99, 235, 0.1);
    color: var(--text-primary);
}

.channel-btn.active {
    background: rgba(37, 99, 235, 0.2);
    color: var(--primary);
    border-color: rgba(37, 99, 235, 0.3);
}

.channel-btn.active::before {
    transform: scaleY(1);
}

.channel-icon {
    font-size: var(--font-size-lg);
    min-width: 20px;
}

.channel-name {
    flex: 1;
    text-align: left;
}

/* ==================== CONVERSATIONS PANEL ==================== */

.conversations-panel {
    width: 360px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.conversations-header {
    padding: var(--space-lg);
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.conversations-title {
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--text-primary);
}

.search-input {
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: var(--font-size-sm);
    transition: all var(--transition-base);
}

.search-input::placeholder {
    color: var(--text-tertiary);
}

.search-input:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--bg-tertiary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.filter-controls {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-top: var(--space-sm);
}

.filter-label {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    font-weight: 500;
}

.filter-select {
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: var(--font-size-sm);
    cursor: pointer;
    transition: all var(--transition-base);
}

.filter-select:hover {
    border-color: var(--primary);
}

.filter-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Guest Filter Styles */
.guest-filter-container {
    display: flex;
    align-items: center;
    margin-top: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: rgba(37, 99, 235, 0.05);
    border: 1px solid rgba(37, 99, 235, 0.1);
    border-radius: var(--radius-md);
    transition: all var(--transition-base);
}

.guest-filter-container:hover {
    background: rgba(37, 99, 235, 0.08);
    border-color: rgba(37, 99, 235, 0.2);
}

.guest-filter-label {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    cursor: pointer;
    user-select: none;
    width: 100%;
}

.guest-filter-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary);
    border-radius: var(--radius-sm);
}

.guest-filter-text {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    font-weight: 500;
}

.guest-filter-checkbox:checked + .guest-filter-text {
    color: var(--primary);
    font-weight: 600;
}

.conversations-list {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-sm);
}

.conversation-item {
    padding: var(--space-md) var(--space-lg);
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-base);
    margin-bottom: var(--space-sm);
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    width: 100%;
    text-align: left;
    pointer-events: auto;
}

.conversation-item:hover {
    background: rgba(37, 99, 235, 0.1);
    border-color: rgba(37, 99, 235, 0.2);
}

.conversation-item.active {
    background: rgba(37, 99, 235, 0.15);
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Indicador visual para conversaciones no leídas (nuevos mensajes) */
.conversation-item.unread {
    background: rgba(59, 130, 246, 0.08);
    border-color: rgba(59, 130, 246, 0.3);
    font-weight: 500;
}

.conversation-item.unread::before {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    background: #3b82f6;
    border-radius: 50%;
    margin-right: var(--space-xs);
    flex-shrink: 0;
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.conversation-item.unread .conversation-name::before {
    content: '● NUEVO';
    display: inline-block;
    background: #3b82f6;
    color: white;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 700;
    margin-right: 8px;
    letter-spacing: 0.5px;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.conversation-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    pointer-events: none;
}

.conversation-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: var(--font-size-sm);
    pointer-events: none;
}

.conversation-time {
    color: var(--text-tertiary);
    font-size: var(--font-size-xs);
    pointer-events: none;
}

.conversation-preview {
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: none;
}

.conversation-badges {
    display: flex;
    gap: var(--space-sm);
    flex-wrap: wrap;
    pointer-events: none;
}

.conversation-channel {
    display: inline-block;
    padding: var(--space-xs) var(--space-sm);
    background: rgba(37, 99, 235, 0.2);
    color: var(--primary-light);
    border-radius: var(--radius-sm);
    font-size: var(--font-size-xs);
    font-weight: 500;
    pointer-events: none;
}

.conversation-tag {
    display: inline-block;
    padding: var(--space-xs) var(--space-sm);
    background: rgba(16, 185, 129, 0.2);
    color: var(--success);
    border-radius: var(--radius-sm);
    font-size: var(--font-size-xs);
    font-weight: 500;
    pointer-events: none;
}

.conversation-ffr-code {
    display: inline-block;
    padding: var(--space-xs) var(--space-sm);
    background: rgba(245, 158, 11, 0.2);
    color: #f59e0b;
    border-radius: var(--radius-sm);
    font-size: var(--font-size-xs);
    font-weight: 600;
    pointer-events: none;
    font-family: 'Courier New', Courier, monospace;
}

/* ==================== CHAT PANEL ==================== */

.chat-panel {
    flex: 1;
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-content {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.chat-header {
    padding: var(--space-lg);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-tertiary) 100%);
}

.chat-header-info {
    flex: 1;
}

.chat-name {
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-xs);
}

.chat-subject {
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
}

.chat-header-actions {
    display: flex;
    gap: var(--space-md);
}

.empty-state {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-tertiary);
}

.empty-state-content {
    text-align: center;
}

.empty-state-title {
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: var(--space-md);
}

.empty-state-text {
    font-size: var(--font-size-sm);
    color: var(--text-tertiary);
}

/* ==================== SIDEBAR FOOTER ==================== */

.sidebar-footer {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    padding-top: var(--space-lg);
    border-top: 1px solid var(--border);
    margin-top: auto;
}

/* ==================== SCROLLBARS ==================== */

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-light);
}

/* ==================== RESPONSIVE ==================== */

@media (max-width: 1400px) {
    .sidebar {
        width: 240px;
    }

    .conversations-panel {
        width: 300px;
    }
}

@media (max-width: 1024px) {
    .sidebar {
        display: none;
    }

    .conversations-panel {
        width: 280px;
    }
}

@media (max-width: 768px) {
    .conversations-panel {
        display: none;
    }

    .chat-panel {
        width: 100%;
    }
}

/* ==================== AUTH MODAL ==================== */

.auth-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 1;
    pointer-events: all;
    transition: opacity var(--transition-base);
}

.auth-modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.auth-modal {
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-tertiary) 100%);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: var(--space-2xl);
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-xl);
    animation: slideUp var(--transition-slow);
}

.auth-header {
    text-align: center;
    margin-bottom: var(--space-2xl);
}

.auth-logo {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: var(--font-size-2xl);
    color: white;
    margin: 0 auto var(--space-lg);
    box-shadow: var(--shadow-lg);
}

.auth-title {
    font-size: var(--font-size-2xl);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--space-sm);
    letter-spacing: -0.5px;
}

.auth-subtitle {
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.form-label {
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--text-primary);
}

.form-input {
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: var(--font-size-base);
    font-family: inherit;
    transition: all var(--transition-base);
}

.form-input::placeholder {
    color: var(--text-tertiary);
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--bg-tertiary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.auth-footer {
    padding: var(--space-lg);
    background: rgba(37, 99, 235, 0.05);
    border-radius: var(--radius-md);
    border: 1px solid rgba(37, 99, 235, 0.1);
}

.auth-footer-text {
    font-size: var(--font-size-xs);
    color: var(--text-tertiary);
    text-align: center;
    margin: 0;
}

/* ==================== FFR LOGO STYLES ==================== */

.auth-logo-img {
    width: 220px;
    height: 220px;
    margin: 0 auto var(--space-2xl);
    object-fit: contain;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.3));
    animation: slideDown var(--transition-slow);
    border-radius: 32px;
    background: white;
    padding: 16px;
}

.sidebar-logo-img {
    width: 90px;
    height: 90px;
    object-fit: contain;
    margin-right: var(--space-md);
    border-radius: 18px;
    background: white;
    padding: 8px;
}

/* ==================== THREAD MESSAGES (Email FFR) ==================== */

.thread-container {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    width: 100%;
    padding: var(--space-sm) 0;
}

.thread-message {
    display: flex;
    flex-direction: column;
    max-width: 75%;
    animation: slideInMessage var(--transition-base) forwards;
}

/* Mensajes del huésped - Izquierda (azul) */
.thread-guest {
    align-self: flex-start;
}

/* Mensajes de FeelFree - Derecha (verde) */
.thread-feelfree {
    align-self: flex-end;
}

.thread-sender-label {
    font-size: var(--font-size-xs);
    font-weight: 600;
    margin-bottom: var(--space-xs);
    padding: 0 var(--space-sm);
    opacity: 0.7;
}

.thread-guest .thread-sender-label {
    color: var(--primary);
    text-align: left;
}

.thread-feelfree .thread-sender-label {
    color: #10b981;
    text-align: right;
}

.thread-bubble {
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-lg);
    line-height: 1.5;
    word-wrap: break-word;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    transition: all var(--transition-base);
}

.thread-guest .thread-bubble {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    border-bottom-left-radius: var(--radius-sm);
}

.thread-feelfree .thread-bubble {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border-bottom-right-radius: var(--radius-sm);
}

.thread-bubble:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

/* Links dentro de thread bubbles */
.thread-bubble a {
    color: rgba(255, 255, 255, 0.9);
    text-decoration: underline;
    font-weight: 500;
}

.thread-bubble a:hover {
    color: white;
}

/* Strong/Bold dentro de thread bubbles */
.thread-bubble strong {
    font-weight: 700;
    color: white;
}

/* Skeleton Loader para conversaciones */
.skeleton-conversation {
    background: var(--bg-secondary);
    padding: var(--space-md);
    margin-bottom: var(--space-sm);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.skeleton-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: var(--space-sm);
}

.skeleton-name {
    width: 40%;
    height: 16px;
    background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--bg-light) 50%, var(--bg-tertiary) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
}

.skeleton-code {
    width: 20%;
    height: 14px;
    background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--bg-light) 50%, var(--bg-tertiary) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
}

.skeleton-message {
    width: 80%;
    height: 14px;
    background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--bg-light) 50%, var(--bg-tertiary) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
    margin-top: var(--space-sm);
}

.skeleton-footer {
    display: flex;
    gap: var(--space-md);
    margin-top: var(--space-sm);
}

.skeleton-badge {
    width: 60px;
    height: 12px;
    background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--bg-light) 50%, var(--bg-tertiary) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Skeleton Loader para mensajes de chat */
.skeleton-chat-message {
    display: flex;
    gap: var(--space-md);
    padding: var(--space-md);
    margin-bottom: var(--space-md);
}

.skeleton-chat-message.received {
    flex-direction: row;
}

.skeleton-chat-message.sent {
    flex-direction: row-reverse;
}

.skeleton-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--bg-light) 50%, var(--bg-tertiary) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    flex-shrink: 0;
}

.skeleton-message-content {
    flex: 1;
    max-width: 70%;
}

.skeleton-message-header {
    display: flex;
    gap: var(--space-sm);
    margin-bottom: var(--space-xs);
}

.skeleton-sender {
    width: 120px;
    height: 12px;
    background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--bg-light) 50%, var(--bg-tertiary) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
}

.skeleton-time {
    width: 60px;
    height: 12px;
    background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--bg-light) 50%, var(--bg-tertiary) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
}

.skeleton-message-bubble {
    background: var(--bg-secondary);
    padding: var(--space-md);
    border-radius: 12px;
}

.skeleton-message-text {
    height: 14px;
    background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--bg-light) 50%, var(--bg-tertiary) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
    margin-bottom: var(--space-xs);
}

.skeleton-message-text:last-child {
    margin-bottom: 0;
}

.skeleton-message-text.short {
    width: 60%;
}

.skeleton-message-text.medium {
    width: 85%;
}

.skeleton-message-text.long {
    width: 100%;
}

/* Responsive para móviles */
@media (max-width: 768px) {
    .thread-message {
        max-width: 85%;
    }

    .thread-bubble {
        padding: var(--space-sm) var(--space-md);
    }
}
