:root {
    --primary-color: #3c0566;
    --primary-dark: #2d044c;
    --secondary-color: #36fdc4;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --info-color: #3b82f6;
    
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --bg-tertiary: #f3f4f6;
    
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-tertiary: #9ca3af;
    
    --border-color: #e5e7eb;
    --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);
    
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-full: 9999px;
}

/* Dark Mode */
[data-theme="dark"] {
    --bg-primary: #1f2937;
    --bg-secondary: #111827;
    --bg-tertiary: #0f1419;
    --text-primary: #f9fafb;
    --text-secondary: #d1d5db;
    --text-tertiary: #9ca3af;
    --border-color: #374151;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.5);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.5);
}

/* Ajustes específicos dark mode */
[data-theme="dark"] .message-sent .message-content {
    background: var(--primary-color);
    color: white;
}

[data-theme="dark"] .message-received .message-content {
    background: #374151;
    color: var(--text-primary);
}

[data-theme="dark"] input,
[data-theme="dark"] textarea,
[data-theme="dark"] select {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--border-color);
}

[data-theme="dark"] .btn-ghost {
    color: var(--text-primary);
}

[data-theme="dark"] .btn-ghost:hover {
    background: var(--bg-tertiary);
}

[data-theme="dark"] .login-container {
    background: var(--bg-secondary);
}

[data-theme="dark"] .login-card {
    background: var(--bg-primary);
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    color: var(--text-primary);
    background: var(--bg-secondary);
    line-height: 1.5;
    /* Mejorar rendering en móviles */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* Prevenir selección de texto en elementos UI */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    /* Mejorar scrolling en iOS */
    -webkit-overflow-scrolling: touch;
    /* Prevenir zoom en inputs en iOS */
    touch-action: manipulation;
}

/* Permitir selección en inputs y contenido de mensajes */
input, textarea, .message-content p {
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

/* PWA: Ocultar barra de direcciones al hacer scroll */
.chat-container,
.admin-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
}

/* Mejorar áreas táctiles */
.btn,
.btn-icon,
a {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* Feedback táctil */
.btn:active,
.btn-icon:active,
.conversation-item:active {
    transform: scale(0.98);
    opacity: 0.8;
}

/* Login Page */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
}

.login-container {
    width: 100%;
    max-width: 420px;
    padding: 20px;
}

.login-box {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 40px;
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.logo {
    display: inline-flex;
    margin-bottom: 20px;
}

.login-header h1 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
}

.login-header p {
    color: var(--text-secondary);
    font-size: 14px;
}

.login-form .form-group {
    margin-bottom: 20px;
}

.login-form label {
    display: block;
    font-weight: 500;
    margin-bottom: 8px;
    font-size: 14px;
}

.login-form input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 15px;
    transition: border-color 0.2s;
}

.login-form input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.login-footer {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    font-size: 13px;
    color: var(--text-secondary);
}

.login-footer ul {
    list-style: none;
    margin-top: 10px;
}

.login-footer li {
    margin: 5px 0;
}

.login-footer code {
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover {
    background: var(--bg-tertiary);
}

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-icon {
    padding: 8px;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-icon:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-send {
    padding: 10px 16px;
}

/* Alert */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    font-size: 14px;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

/* Chat Container */
.chat-container {
    display: flex;
    height: 100vh;
    max-width: 1600px;
    margin: 0 auto;
    background: var(--bg-primary);
}

/* Sidebar */
.sidebar {
    width: 350px;
    background: var(--bg-primary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.avatar {
    width: 45px;
    height: 45px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 18px;
}

.user-details h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 2px;
}

.user-type {
    font-size: 13px;
    color: var(--text-secondary);
}

.sidebar-actions {
    display: flex;
    gap: 8px;
}

/* Conversations List */
.conversations-list {
    flex: 1;
    overflow-y: auto;
}

.conversations-header {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
}

.conversations-header h4 {
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.conversation-item {
    display: flex;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    transition: background 0.2s;
}

.conversation-item:hover {
    background: var(--bg-secondary);
}

.conversation-item.active {
    background: var(--bg-secondary);
    border-left: 3px solid var(--primary-color);
}

.conversation-avatar {
    width: 45px;
    height: 45px;
    min-width: 45px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.conversation-info {
    flex: 1;
    min-width: 0;
}

.conversation-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}

.conversation-header h5 {
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversation-header .time {
    font-size: 12px;
    color: var(--text-tertiary);
    white-space: nowrap;
}

.conversation-preview {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.conversation-preview p {
    font-size: 14px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0;
}

/* Badge */
.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background: var(--primary-color);
    color: white;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 600;
}

/* Chat Area */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
}

.chat-header {
    padding: 20px 24px;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-header-info h2 {
    font-size: 18px;
    font-weight: 600;
}

.status {
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 500;
}

.status-active {
    background: #d1fae5;
    color: #065f46;
}

.status-closed {
    background: #fee2e2;
    color: #991b1b;
}

.status-pending {
    background: #fef3c7;
    color: #92400e;
}

.priority {
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 500;
}

.priority-low {
    background: #e0e7ff;
    color: #3730a3;
}

.priority-normal {
    background: #dbeafe;
    color: #1e40af;
}

.priority-high {
    background: #fed7aa;
    color: #9a3412;
}

.priority-urgent {
    background: #fecaca;
    color: #991b1b;
}

.chat-header-actions {
    display: flex;
    gap: 8px;
}

/* Messages Container */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.message {
    display: flex;
    gap: 12px;
    max-width: 70%;
}

.message-sent {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message-received {
    align-self: flex-start;
}

.message-avatar {
    width: 35px;
    height: 35px;
    min-width: 35px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
}

.message-content {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: 12px 16px;
    box-shadow: var(--shadow-sm);
}

.message-sent .message-content {
    background: var(--primary-color);
    color: white;
}

.message-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.sender-name {
    font-weight: 600;
    font-size: 13px;
}

.message-sent .sender-name {
    color: rgba(255, 255, 255, 0.9);
}

.message-time {
    font-size: 11px;
    color: var(--text-tertiary);
}

.message-sent .message-time {
    color: rgba(255, 255, 255, 0.7);
}

.message-content p {
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
}

.message-image img {
    max-width: 100%;
    border-radius: var(--radius-md);
    margin-top: 8px;
    cursor: pointer;
    transition: transform 0.2s;
}

.message-image img:hover {
    transform: scale(1.02);
}

.message-file {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    margin-top: 8px;
}

.message-sent .message-file {
    background: rgba(255, 255, 255, 0.1);
}

.file-info {
    flex: 1;
}

.file-info a {
    display: block;
    font-weight: 500;
    color: var(--primary-color);
    text-decoration: none;
    margin-bottom: 2px;
}

.message-sent .file-info a {
    color: white;
}

.file-size {
    font-size: 12px;
    color: var(--text-secondary);
}

.message-sent .file-size {
    color: rgba(255, 255, 255, 0.7);
}

/* Message Input */
.message-input-container {
    padding: 20px 24px;
    background: var(--bg-primary);
    border-top: 1px solid var(--border-color);
    position: relative; /* Para emoji picker */
}

/* Emoji picker styles */
.emoji-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background 0.2s;
    line-height: 1;
}

.emoji-btn:hover {
    background: var(--bg-secondary);
}

.emoji-btn:active {
    transform: scale(0.95);
}

.message-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.file-preview {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
}

.preview-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-remove {
    width: 28px;
    height: 28px;
    border: none;
    background: var(--danger-color);
    color: white;
    border-radius: var(--radius-full);
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    transition: all 0.2s;
}

.btn-remove:hover {
    transform: scale(1.1);
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.input-wrapper textarea {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    font-size: 15px;
    font-family: inherit;
    resize: none;
    max-height: 120px;
}

.input-wrapper textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Empty States */
.empty-state {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-secondary);
}

.empty-chat {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    color: var(--text-secondary);
}

.empty-chat h3 {
    margin-top: 20px;
    font-size: 20px;
    font-weight: 600;
}

.empty-chat p {
    margin-top: 8px;
    font-size: 14px;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow: auto;
}

.modal-image {
    max-width: 90%;
    max-height: 90vh;
    padding: 20px;
}

.modal-image img {
    width: 100%;
    height: auto;
    border-radius: var(--radius-md);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.btn-close {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-close:hover {
    color: var(--text-primary);
    transform: scale(1.1);
}

.modal-content form {
    padding: 24px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 8px;
    font-size: 14px;
}

.form-group input[type="text"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 15px;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.feedback-types {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.feedback-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s;
}

.feedback-option:hover {
    border-color: var(--primary-color);
}

.feedback-option input {
    margin: 0;
}

.feedback-option input:checked + span {
    font-weight: 600;
}

.rating-stars {
    display: flex;
    flex-direction: row-reverse;
    justify-content: flex-end;
    gap: 5px;
}

.rating-stars input {
    display: none;
}

.rating-stars label {
    font-size: 32px;
    color: var(--border-color);
    cursor: pointer;
    transition: color 0.2s;
}

.rating-stars input:checked ~ label,
.rating-stars label:hover,
.rating-stars label:hover ~ label {
    color: #fbbf24;
}

.modal-footer {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    padding: 20px 24px;
    border-top: 1px solid var(--border-color);
    margin-top: 20px;
}

/* Responsive */
@media (max-width: 768px) {
    /* Container principal mobile-first */
    .chat-container {
        flex-direction: column;
        position: relative;
    }
    
    /* Sidebar optimizado para móvil - SIN botón flotante */
    .sidebar {
        width: 100%;
        max-width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        position: relative;
        z-index: 100;
    }
    
    /* Logo PEQUEÑO como avatar en móvil */
    .sidebar-header .branding-logo {
        display: block !important;
        text-align: left !important;
        margin: 0 !important;
    }
    
    .sidebar-header .branding-logo img {
        width: 28px !important;
        height: 28px !important;
        border-radius: 6px !important;
        object-fit: cover;
    }
    
    /* Header UNA SOLA LÍNEA - todo horizontal */
    .sidebar-header {
        padding: 6px 10px;
        display: flex;
        align-items: center;
        gap: 8px;
    }
    
    .sidebar-header .user-info {
        flex: 1;
        display: flex;
        flex-direction: row;
        gap: 6px;
        margin: 0;
        align-items: center;
        min-width: 0;
    }
    
    .sidebar-header .avatar {
        width: 28px;
        height: 28px;
        font-size: 12px;
        flex-shrink: 0;
    }
    
    .sidebar-header .user-details {
        flex: 1;
        min-width: 0;
    }
    
    .sidebar-header .user-details h3 {
        font-size: 12px;
        margin: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .sidebar-header .user-details p,
    .sidebar-header .user-details .user-type {
        display: none; /* Ocultar subtítulo */
    }
    
    .sidebar-actions {
        display: flex;
        gap: 3px;
        margin: 0;
        flex-shrink: 0;
        flex-wrap: nowrap;
    }
    
    .sidebar-actions .btn-sm {
        padding: 4px 6px;
        font-size: 10px;
        height: 24px;
        white-space: nowrap;
    }
    
    .sidebar-actions .btn-icon-sm {
        width: 24px;
        height: 24px;
        padding: 4px;
        font-size: 12px;
    }
    
    /* Toggle SIEMPRE VISIBLE - Fuera de la lista */
    .conversations-header {
        padding: 8px 12px;
        background: var(--primary-color);
        color: white;
        cursor: pointer;
        user-select: none;
        font-weight: 600;
        font-size: 11px;
        letter-spacing: 0.5px;
        display: flex !important; /* SIEMPRE visible */
        align-items: center;
        justify-content: space-between;
        transition: background 0.2s;
        border-bottom: 2px solid var(--secondary-color);
        flex-shrink: 0; /* No se encoge */
    }
    
    .conversations-header h4 {
        margin: 0;
        font-size: 11px;
        font-weight: 600;
    }
    
    .conversations-header:active {
        background: var(--primary-dark);
    }
    
    /* Flecha GRANDE - Siempre visible */
    .conversations-header::after {
        content: '▲';
        transition: transform 0.3s ease;
        font-size: 18px;
        color: var(--secondary-color);
        font-weight: bold;
        margin-left: 8px;
    }
    
    /* Lista de conversaciones que se expande/colapsa */
    .conversations-list {
        max-height: 55vh;
        overflow-y: auto;
        transition: max-height 0.3s ease;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
        scrollbar-color: var(--primary-color) var(--bg-secondary);
    }
    
    .conversations-list::-webkit-scrollbar {
        width: 4px;
    }
    
    .conversations-list::-webkit-scrollbar-thumb {
        background: var(--primary-color);
        border-radius: 2px;
    }
    
    /* Cuando está colapsada - la flecha rota */
    .sidebar:not(.expanded) .conversations-header::after {
        transform: rotate(180deg);
    }
    
    /* Cuando está colapsada - la LISTA se oculta */
    .sidebar:not(.expanded) .conversations-list {
        max-height: 0 !important;
        overflow: hidden;
    }
    
    /* Conversaciones compactas */
    .conversation-item {
        padding: 8px 12px;
        border-bottom: 1px solid var(--border-color);
    }
    
    .conversation-avatar {
        width: 36px;
        height: 36px;
        min-width: 36px;
        font-size: 14px;
    }
    
    .conversation-header h5 {
        font-size: 13px;
    }
    
    .conversation-preview p {
        font-size: 12px;
    }
    
    .conversation-time {
        font-size: 10px;
    }
    
    /* Header clickeable con indicador visual mejor */
    .conversations-header {
        padding: 12px 15px;
        background: var(--bg-secondary);
        cursor: pointer;
        user-select: none;
        position: sticky;
        top: 0;
        z-index: 10;
        font-weight: 600;
        display: flex;
        align-items: center;
        justify-content: space-between;
        transition: background 0.2s;
        border-bottom: 1px solid var(--border-color);
    }
    
    .conversations-header:active {
        background: var(--border-color);
    }
    
    /* Flecha MUY VISIBLE */
    .conversations-header::after {
        content: '▲';
        transition: transform 0.3s ease;
        font-size: 18px;
        color: var(--secondary-color);
        font-weight: bold;
        text-shadow: 0 2px 4px rgba(0,0,0,0.2);
    }
    
    .sidebar:not(.expanded) .conversations-header::after {
        transform: rotate(180deg);
        color: var(--primary-color);
    }
    
    /* Hint text visible */
    .conversations-header::before {
        content: 'Toca para ' attr(data-state);
        font-size: 10px;
        color: var(--text-tertiary);
        font-weight: normal;
        margin-right: auto;
        padding-left: 8px;
        opacity: 0.7;
    }
    
    /* Lista con mejor scroll */
    .conversations-list {
        max-height: 50vh;
        overflow-y: auto;
        transition: max-height 0.3s ease;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
        scrollbar-color: var(--primary-color) var(--bg-secondary);
    }
    
    /* Scroll bar personalizada */
    .conversations-list::-webkit-scrollbar {
        width: 6px;
    }
    
    .conversations-list::-webkit-scrollbar-track {
        background: var(--bg-secondary);
    }
    
    .conversations-list::-webkit-scrollbar-thumb {
        background: var(--primary-color);
        border-radius: 3px;
    }
    
    /* Cuando está colapsada */
    .sidebar:not(.expanded) .conversations-list {
        max-height: 0 !important;
        overflow: hidden;
    }
    
    /* Conversaciones compactas */
    .conversation-item {
        padding: 10px 15px;
        border-bottom: 1px solid var(--border-color);
    }
    
    .conversation-avatar {
        width: 40px;
        height: 40px;
        min-width: 40px;
        font-size: 16px;
    }
    
    .conversation-header h5 {
        font-size: 14px;
    }
    
    .conversation-preview p {
        font-size: 13px;
    }
    
    /* Chat area optimizada */
    .chat-area {
        flex: 1;
        min-height: 0;
        display: flex;
        flex-direction: column;
    }
    
    .chat-header {
        padding: 12px 15px;
        flex-shrink: 0;
    }
    
    .chat-header-info h2 {
        font-size: 16px;
    }
    
    /* Mensajes optimizados */
    .messages-container {
        flex: 1;
        padding: 15px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .message {
        max-width: 85%;
        margin-bottom: 12px;
    }
    
    .message-avatar {
        width: 32px;
        height: 32px;
        min-width: 32px;
        font-size: 14px;
    }
    
    .message-content {
        padding: 10px 12px;
        font-size: 14px;
    }
    
    .message-header {
        margin-bottom: 4px;
    }
    
    .sender-name {
        font-size: 12px;
    }
    
    .message-time {
        font-size: 10px;
    }
    
    /* Input de mensaje mobile-optimizado */
    .message-input-container {
        padding: 10px 12px;
        flex-shrink: 0;
        background: var(--bg-primary);
        border-top: 1px solid var(--border-color);
    }
    
    .input-wrapper {
        gap: 6px;
    }
    
    .input-wrapper textarea {
        font-size: 16px; /* Prevenir zoom en iOS */
        padding: 10px 12px;
        min-height: 42px;
    }
    
    /* Botones táctiles más grandes */
    .btn-icon {
        min-width: 42px;
        min-height: 42px;
        padding: 10px;
    }
    
    .btn-send {
        min-width: 42px;
        min-height: 42px;
        padding: 10px 12px;
    }
    
    /* Admin container en móvil */
    .admin-container {
        flex-direction: column;
    }
    
    .admin-sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        padding: 12px;
        max-height: none;
    }
    
    .admin-nav {
        display: flex;
        overflow-x: auto;
        gap: 8px;
        margin-bottom: 12px;
        -webkit-overflow-scrolling: touch;
    }
    
    .admin-nav a {
        padding: 8px 12px;
        font-size: 13px;
        white-space: nowrap;
        flex-shrink: 0;
    }
    
    .admin-content {
        padding: 15px;
    }
    
    .admin-header h1 {
        font-size: 20px;
    }
    
    /* Stats grid 2 columnas */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    
    .stat-card {
        padding: 16px;
    }
    
    .stat-card .value {
        font-size: 24px;
    }
    
    /* Tablas responsive */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .table {
        font-size: 12px;
        min-width: 600px;
    }
    
    .table th,
    .table td {
        padding: 8px 6px;
    }
    
    /* Ocultar columnas menos importantes */
    .table th:nth-child(n+6),
    .table td:nth-child(n+6) {
        display: none;
    }
    
    /* Modales full screen en móvil */
    .modal-content {
        width: 95%;
        max-width: 95%;
        margin: 20px auto;
    }
    
    /* File preview compacto */
    .file-preview {
        padding: 8px;
    }
    
    /* Empty states */
    .empty-chat {
        padding: 40px 20px;
    }
    
    .empty-chat svg {
        width: 60px;
        height: 60px;
    }
    
    .empty-chat h3 {
        font-size: 18px;
    }
}

/* Landscape en móviles */
@media (max-width: 768px) and (orientation: landscape) {
    .sidebar.expanded .conversations-list {
        max-height: 45vh;
    }
    
    .messages-container {
        max-height: calc(100vh - 160px);
    }
}

/* Tablets */
@media (min-width: 769px) and (max-width: 1024px) {
    .sidebar {
        width: 280px;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .admin-sidebar {
        width: 220px;
    }
    
    .message {
        max-width: 75%;
    }
}

/* Móviles pequeños */
@media (max-width: 375px) {
    .stat-card {
        padding: 12px;
    }
    
    .stat-card .value {
        font-size: 20px;
    }
    
    .stat-card h3 {
        font-size: 11px;
    }
    
    .conversation-header h5 {
        font-size: 13px;
    }
    
    .message-content {
        font-size: 13px;
        padding: 8px 10px;
    }
    
    .chat-header-info h2 {
        font-size: 14px;
    }
    
    .admin-header h1 {
        font-size: 18px;
    }
}

/* Fix para teclado virtual en iOS */
@supports (-webkit-touch-callout: none) {
    .message-input-container {
        padding-bottom: max(10px, env(safe-area-inset-bottom));
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

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

::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}
