@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ===================================
   TEMA OSCURO (default)
   =================================== */
:root {
    --bg-base: #121417;
    --bg-surface: #1e2024;
    --bg-elevated: #282a2f;

    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --accent: #0ea5e9;

    --text-main: #f3f4f6;
    --text-muted: #9ca3af;

    --border-color: #373b41;

    --danger: #ef4444;
    --success: #10b981;
    --warning: #f59e0b;

    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-full: 9999px;

    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.5), 0 2px 4px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.3);

    --sidebar-width-expanded: 280px;
    --sidebar-width-collapsed: 80px;
    --sidebar-width: var(--sidebar-width-collapsed);
}

/* ===================================
   TEMA CLARO
   =================================== */
[data-theme="light"] {
    --bg-base: #f0f2f5;
    --bg-surface: #ffffff;
    --bg-elevated: #e8eaed;

    --text-main: #1a1c1e;
    --text-muted: #5f6368;

    --border-color: #d1d5db;

    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.12), 0 2px 4px -1px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.12), 0 4px 6px -2px rgba(0, 0, 0, 0.08);

    /* Botones y acentos: idénticos en ambos temas */
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --accent: #0ea5e9;
    --danger: #ef4444;
    --success: #10b981;
    --warning: #f59e0b;
}

/* Transición suave al cambiar tema */
*,
*::before,
*::after {
    transition: background-color 0.25s ease, color 0.15s ease, border-color 0.25s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-base);
    color: var(--text-main);
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
}

body.auth-layout {
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at top, var(--bg-surface) 0%, var(--bg-base) 100%);
}

/* -------------------------------------
   SIDEBAR
------------------------------------- */
.sidebar {
    width: var(--sidebar-width-expanded) !important;
    background-color: var(--bg-surface);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    z-index: 1000;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    overflow-x: hidden;
    white-space: nowrap;
    box-shadow: none;
}

.sidebar.open {
    transform: translateX(0);
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.4);
}

.sidebar .sidebar-brand div,
.sidebar .nav-text,
.sidebar .user-details {
    opacity: 1 !important;
    pointer-events: auto !important;
}

.sidebar-brand {
    padding: 24px 26px;
    display: flex;
    align-items: center;
    gap: 16px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-brand i {
    font-size: 28px;
    color: var(--accent);
}

.sidebar-brand h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.2;
}

.sidebar-brand span {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.sidebar-nav {
    flex: 1;
    padding: 24px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    overflow-x: hidden;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s ease;
}

.nav-item i {
    font-size: 18px;
    width: 24px;
    text-align: center;
}

.nav-item:hover,
.nav-item.active {
    background-color: var(--bg-elevated);
    color: var(--text-main);
}

.nav-item.active {
    background-color: rgba(131, 144, 158, 0.1);
    color: var(--primary);
    border-right: 3px solid var(--primary);
}

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

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

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

.user-details {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-main);
}

.user-role {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.logout-btn {
    color: var(--text-muted);
    text-decoration: none;
    padding: 8px;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.logout-btn:hover {
    color: var(--danger);
    background-color: rgba(239, 68, 68, 0.1);
}

.config-btn {
    color: var(--text-muted);
    text-decoration: none;
    padding: 8px;
    border-radius: 8px;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.config-btn:hover {
    color: var(--primary);
    background-color: rgba(59, 130, 246, 0.1);
}

.config-btn.active {
    color: var(--primary);
    background-color: rgba(59, 130, 246, 0.1);
}

/* -------------------------------------
   MAIN CONTENT
------------------------------------- */
.main-content {
    flex: 1;
    margin-left: 0;
    padding: 80px 24px 20px 24px !important;
    /* Offset by header height + padding */
    min-height: calc(100vh - 60px);
    display: flex;
    flex-direction: column;
    width: 100%;
    min-width: 0;
    /* Para evitar desbordamiento del grid */
}

/* For pages without sidebar (login) */
body.auth-layout .main-content {
    margin-left: 0 !important;
    padding: 20px;
    width: 100%;
    align-items: center;
    justify-content: center;
}

/* -------------------------------------
   COMPONENTS
------------------------------------- */
.auth-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.auth-card h1 {
    margin-bottom: 8px;
    font-size: 1.8rem;
    color: var(--text-main);
}

.auth-card p {
    color: var(--text-muted);
    margin-bottom: 24px;
    font-size: 0.9rem;
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
select,
textarea {
    width: 100%;
    padding: 12px 16px;
    background-color: var(--bg-base);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-main);
    font-size: 0.95rem;
    transition: all 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(131, 144, 158, 0.2);
}

.action-button {
    background-color: var(--primary);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.action-button:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
}

.action-button.danger {
    background-color: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

.action-button.danger:hover {
    background-color: var(--danger);
    color: white;
}

/* -------------------------------------
   TABLES & PANELS (Admin)
------------------------------------- */
.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
}

.admin-header h1 {
    font-size: 2rem;
    font-weight: 700;
}

.panel-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 32px;
    box-shadow: var(--shadow-md);
}

.panel-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.panel-card-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.table-responsive {
    overflow-x: auto;
}

.modern-table {
    width: 100%;
    border-collapse: collapse;
}

.modern-table th {
    text-align: left;
    padding: 16px;
    background-color: var(--bg-base);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border-color);
}

.modern-table td {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
    font-size: 0.95rem;
}

.modern-table tr:hover td {
    background-color: rgba(255, 255, 255, 0.02);
}

.modern-table tr:last-child td {
    border-bottom: none;
}

.badge {
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    background-color: var(--bg-base);
    color: var(--text-muted);
}

.badge.admin {
    background-color: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.badge.usuario {
    background-color: rgba(59, 130, 246, 0.1);
    color: var(--primary);
}

/* -------------------------------------
   MODALS
------------------------------------- */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(10, 12, 14, 0.85);
    backdrop-filter: blur(8px);
    z-index: 10000;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 600px;
    box-shadow: var(--shadow-lg);
    animation: modalScale 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
}

@keyframes modalScale {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

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

.modal-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.close-modal {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 24px;
    cursor: pointer;
    transition: color 0.2s;
}

.close-modal:hover {
    color: var(--text-main);
}

.modal-body {
    padding: 24px;
    max-height: 70vh;
    overflow-y: auto;
}

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

/* -------------------------------------
   CHAT UI
------------------------------------- */
.chat-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 80px);
    /* 40px padding top/bottom */
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.chat-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--bg-surface);
}

.chat-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.message {
    display: flex;
    gap: 16px;
    max-width: 85%;
}

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

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

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.message.user .message-avatar {
    background-color: var(--primary);
    color: white;
}

.message.assistant .message-avatar {
    background-color: var(--bg-elevated);
    color: var(--accent);
}

.message-content {
    background-color: var(--bg-elevated);
    padding: 16px;
    border-radius: var(--radius-lg);
    color: var(--text-main);
    line-height: 1.6;
    font-size: 0.95rem;
}

.message.user .message-content {
    background-color: var(--primary);
    color: white;
    border-top-right-radius: 4px;
}

.message.assistant .message-content {
    border-top-left-radius: 4px;
}

.chat-input-area {
    padding: 24px;

    background-color: var(--bg-surface);
    display: flex;
    gap: 12px;
}

.chat-input-area textarea {
    flex: 1;
    resize: none;
    height: 52px;
    padding: 14px 16px;

    line-height: 1.5;
}

.chat-send-btn {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-full);
    background-color: var(--primary);
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s;
}

.chat-send-btn:hover {
    background-color: var(--primary-hover);
    transform: scale(1.05);
}

/* Flash Messages */
.flash-toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.flash-toast {
    padding: 16px 24px;
    border-radius: var(--radius-md);
    background-color: var(--bg-elevated);
    color: var(--text-main);
    box-shadow: var(--shadow-lg);
    border-left: 4px solid var(--primary);
}

.toast-success {
    border-left-color: var(--success);
}

.toast-error {
    border-left-color: var(--danger);
}

/* Utilities */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

/* -------------------------------------
   MOBILE STYLING & RESPONSIVENESS
   ------------------------------------- */
.mobile-header {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 60px;
    background-color: var(--bg-surface);
    /*  border-bottom: 1px solid var(--border-color);*/
    z-index: 999;
    align-items: center;
    padding: 0 20px;
    justify-content: space-between;
    box-shadow: var(--shadow-md);
}

/* Configuración por defecto: Modo Teléfono (pantallas < 992px) */
.mobile-new-chat-btn {
    display: none !important;
}

#new-chat-btn {
    display: flex !important;
}

@media (max-width: 360px) {
    .mobile-new-chat-text {
        display: none;
    }
}

#mobile-sidebar-toggle {
    background: none;
    border: none;
    color: var(--text-main);
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    transition: background-color 0.2s, transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1001;
}

#mobile-sidebar-toggle:hover {
    background-color: var(--bg-elevated);
}

#mobile-sidebar-toggle:active {
    transform: scale(0.95);
}



.mobile-header-title {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 1;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.mobile-header-title i {
    color: var(--accent);
}



@media (max-width: 768px) {
    .main-content {
        padding: 80px 16px 20px 16px !important;
        /* Slightly tighter padding on mobile */
    }

    .grid-2 {
        grid-template-columns: 1fr;
    }
}

/* -------------------------------------
   SIDEBAR DESKTOP: Historial anidado
   ------------------------------------- */
.nav-group {
    display: flex;
    flex-direction: column;
}

.nav-group-arrow {
    color: var(--text-muted);
    flex-shrink: 0;
}

.nav-group-arrow {
    opacity: 1;
}

.sidebar-history-list {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding-left: 16px;
}

.sidebar-history-list.open {
    max-height: none;
    overflow: visible;
}

.sidebar-history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 7px 12px;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 400;
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s;
    position: relative;
}

.sidebar-history-content {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow: hidden;
    flex-grow: 1;
}

.sidebar-history-content i {
    font-size: 12px;
    flex-shrink: 0;
}

.sidebar-history-content span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-history-dropdown {
    position: relative;
    flex-shrink: 0;
}

.sidebar-history-trigger {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    width: 24px;
    height: 24px;
    font-size: 0.85rem;
    border-radius: var(--radius-sm);
    transition: color 0.15s, background-color 0.15s, opacity 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
}

.sidebar-history-item:hover .sidebar-history-trigger,
.sidebar-history-dropdown.active .sidebar-history-trigger {
    opacity: 1;
    pointer-events: auto;
}

.sidebar-history-trigger:hover {
    color: var(--text-main);
    background-color: var(--bg-hover);
}

.sidebar-history-menu {
    position: absolute;
    right: 0;
    top: 100%;
    z-index: 1000;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
    padding: 4px;
    display: none;
    min-width: 120px;
    flex-direction: column;
}

.sidebar-history-dropdown.active .sidebar-history-menu {
    display: flex;
}

.sidebar-menu-item {
    background: none;
    border: none;
    color: var(--text-color);
    padding: 8px 12px;
    font-size: 0.8rem;
    text-align: left;
    cursor: pointer;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    transition: background-color 0.15s, color 0.15s;
}

.sidebar-menu-item:hover {
    background-color: var(--bg-hover);
    color: var(--text-main);
}

.sidebar-menu-item.btn-delete:hover {
    color: var(--danger);
    background-color: rgba(239, 68, 68, 0.1);
}

.sidebar-history-item:hover {
    background-color: var(--bg-elevated);
    color: var(--text-main);
}

.sidebar-history-item.active-chat {
    color: var(--primary);
    background-color: rgba(59, 130, 246, 0.08);
}

.sidebar-history-loading,
.sidebar-history-empty {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 12px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ===================================
   THEME TOGGLE SWITCH (sidebar)
   =================================== */
.theme-toggle-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border-top: 1px solid var(--border-color);
}

.theme-icon {
    font-size: 14px;
    color: var(--text-muted);
    transition: color 0.2s;
    flex-shrink: 0;
}

.theme-icon.active {
    color: var(--accent);
}

.theme-switch {
    position: relative;
    width: 40px;
    height: 22px;
    flex-shrink: 0;
}

.theme-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.theme-switch-track {
    position: absolute;
    inset: 0;
    background-color: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: background-color 0.25s;
}

.theme-switch-track::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background-color: var(--text-muted);
    top: 2px;
    left: 2px;
    transition: transform 0.25s, background-color 0.25s;
}

.theme-switch input:checked+.theme-switch-track {
    background-color: rgba(59, 130, 246, 0.2);
    border-color: var(--primary);
}

.theme-switch input:checked+.theme-switch-track::after {
    transform: translateX(18px);
    background-color: var(--primary);
}

/* Ocultar texto del toggle cuando sidebar colapsada */
.sidebar:not(.sidebar-expanded) .theme-toggle-label {
    display: none;
}

/* ===================================
   MODAL ARCHIVADO
   =================================== */
.archive-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(10, 12, 14, 0.85);
    backdrop-filter: blur(8px);
    z-index: 10100;
    align-items: center;
    justify-content: center;
}

.archive-modal-overlay.active {
    display: flex;
}

.archive-modal {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 540px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    animation: modalScale 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.archive-modal-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.archive-modal-header h2 i {
    color: var(--accent);
}

.archive-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 24px;
}

.archive-chat-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background 0.15s;
    border: 1px solid transparent;
}

.archive-chat-item:hover {
    background: var(--bg-elevated);
}

.archive-chat-item.selected {
    background: rgba(59, 130, 246, 0.1);
    border-color: rgba(59, 130, 246, 0.3);
}

.archive-chat-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
    flex-shrink: 0;
}

.archive-chat-item-title {
    flex: 1;
    font-size: 0.9rem;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.archive-chat-item-date {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.archive-modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.archive-count-label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Ajuste tema claro: input y textarea fondos */
[data-theme="light"] input[type="text"],
[data-theme="light"] input[type="password"],
[data-theme="light"] input[type="email"],
[data-theme="light"] select,
[data-theme="light"] textarea {
    background-color: #fff;
    color: var(--text-main);
    border-color: var(--border-color);
}

[data-theme="light"] .message.assistant .message-content {
    background-color: #e9ecef;
    color: #1a1c1e;
}

[data-theme="light"] .sidebar {
    background-color: #ffffff;
}

[data-theme="light"] .mobile-header {
    background-color: #ffffff;
}

/* EFECTOS DE GRABACIÓN DE VOZ (PULSO ROJO PREMIUM) */
@keyframes pulse-red {
    0% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.5);
        transform: scale(1);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);
        transform: scale(1.05);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
        transform: scale(1);
    }
}

.recording,
.listening {
    background-color: var(--danger, #ef4444) !important;
    color: white !important;
    animation: pulse-red 1.5s infinite !important;
    border-color: var(--danger, #ef4444) !important;
}

.recording i,
.listening i {
    color: white !important;
}

/* ===================================
   COMPUTADORA SIDEBAR COMPORTAMIENTO (YouTube Style)
   =================================== */
@media (min-width: 992px) {
    .sidebar {
        transform: translateX(0) !important;
        /* Visible por defecto */
        box-shadow: none !important;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    }

    body.sidebar-collapsed .sidebar {
        transform: translateX(-100%) !important;
        /* Se desliza fuera */
    }

    .mobile-header {
        left: var(--sidebar-width-expanded) !important;
        width: calc(100% - var(--sidebar-width-expanded)) !important;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    }

    body.sidebar-collapsed .mobile-header {
        left: 0 !important;
        width: 100% !important;
    }

    .main-content {
        margin-left: var(--sidebar-width-expanded) !important;
        /* Desplazado por defecto */
        transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    }

    body.sidebar-collapsed .main-content {
        margin-left: 0 !important;
        /* Se expande */
    }

    .mobile-header-title {
        left: calc(50vw - var(--sidebar-width-expanded)) !important;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    }

    body.sidebar-collapsed .mobile-header-title {
        left: 50vw !important;
    }

    /* Sin backdrop en modo computadora */
    .sidebar-backdrop {
        display: none !important;
    }


}

/* ===================================
   COMPORTAMIENTO SIDEBAR EN MÓVIL (< 992px)
   =================================== */
@media (max-width: 991px) {
    .sidebar {
        top: 0 !important;
        height: 100vh !important;
        z-index: 10000 !important;
    }

    body.sidebar-open #mobile-sidebar-toggle {
        transform: translateX(calc(var(--sidebar-width-expanded) - 10px));
        z-index: 10001;
        background-color: var(--bg-surface);
        box-shadow: var(--shadow-md);
        color: var(--text-main);
    }
}

/* --- BOTÓN DE CONVERSACIÓN DE VOZ CONTINUA --- */
.voice-conversation-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background-color: var(--bg-surface);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    font-size: 1.1rem;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.2s, border-color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.08);
}

.voice-conversation-btn:hover {
    background-color: var(--bg-elevated);
    border-color: var(--primary);
    transform: scale(1.05);
}

.voice-conversation-btn.active {
    background-color: var(--danger) !important;
    color: white !important;
    animation: pulse-recording 1.5s infinite;
}

@keyframes pulse-recording {
    0% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
    }

    70% {
        box-shadow: 0 0 0 15px rgba(239, 68, 68, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

/* Responsividad de los botones de voz */
@media (min-width: 992px) {
    .mobile-voice-btn {
        display: none !important;
    }
}

@media (max-width: 991px) {
    .mobile-voice-btn {
        display: flex !important;
    }

    /* Ocultar el botón de voz del header del chat en móviles */
    .chat-window .chat-header .voice-conversation-btn {
        display: none !important;
    }
}

/* ==========================================================================
   PREMIUM ATTACH DROPDOWN & 7-QUESTION EVALUATION SYSTEM
   ========================================================================== */

/* --- Dropdown de Adjuntos Premium --- */
.attach-dropdown {
    display: none;
    position: absolute;
    bottom: 58px;
    right: 14px;
    background: var(--bg-surface, #1e1e24);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: var(--shadow-lg), 0 10px 30px rgba(0, 0, 0, 0.4);
    width: 320px;
    max-width: 90vw;
    z-index: 1000;
    overflow: hidden;
    animation: slideUpFade 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    backdrop-filter: blur(12px);
}

.attach-dropdown.show {
    display: block;
}

@keyframes slideUpFade {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.98);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.attach-dropdown-item {
    background: transparent;
    border: none;
    width: 100%;
    text-align: left;
    padding: 12px 18px;
    color: var(--text-main);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: background-color 0.2s, color 0.2s;
}

.attach-dropdown-item:hover {
    background-color: var(--bg-elevated);
    color: var(--primary);
}

.attach-dropdown-divider {
    height: 1px;
    background-color: var(--border-color);
    margin: 4px 0;
}

.attach-dropdown-header {
    padding: 8px 18px 4px 18px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.recent-documents-list {
    max-height: 200px;
    overflow-y: auto;
    padding: 4px 8px;
}

/* Fina barra de scroll para recientes */
.recent-documents-list::-webkit-scrollbar {
    width: 5px;
}

.recent-documents-list::-webkit-scrollbar-track {
    background: transparent;
}

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

.recent-documents-list::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

.recent-doc-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    border-radius: 8px;
    margin-bottom: 4px;
    transition: background-color 0.2s;
}

.recent-doc-item:hover {
    background-color: var(--bg-elevated);
}

.recent-doc-info {
    display: flex;
    align-items: center;
    gap: 10px;
    overflow: hidden;
    flex: 1;
}

.recent-doc-info i {
    color: #ef4444;
    /* Rojo PDF */
    font-size: 1.1rem;
    flex-shrink: 0;
}

.recent-doc-details {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.recent-doc-name {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.recent-doc-date {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.recent-doc-actions {
    display: flex;
    gap: 4px;
}

.recent-action-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-size: 0.85rem;
}

.recent-action-btn:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}

.recent-action-btn.add-btn:hover {
    color: var(--success);
    background-color: rgba(16, 185, 129, 0.1);
}

.recent-action-btn.download-btn:hover {
    color: var(--primary);
    background-color: rgba(59, 130, 246, 0.1);
}

.recent-action-btn.delete-btn:hover {
    color: var(--danger);
    background-color: rgba(239, 68, 68, 0.1);
}


/* --- Tarjeta de Cuestionario de 7 Preguntas Premium --- */
.evaluation-card.multi-question {
    padding: 24px;
    background: transparent;
    border: none;
    box-shadow: none;
}

.evaluation-body-grid {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 24px;
    margin-top: 16px;
}

/* Panel de Navegación Izquierdo */
.evaluation-nav-panel {
    border-right: 1px solid var(--border-color);
    padding-right: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.nav-panel-title {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.8px;
    margin-bottom: 4px;
}

.evaluation-nav-dots {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.eval-nav-btn {
    background: var(--bg-elevated, #24252b);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 10px 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--text-muted);
    text-align: left;
}

.eval-nav-btn:hover {
    background-color: rgba(59, 130, 246, 0.08);
    border-color: rgba(59, 130, 246, 0.3);
    color: var(--text-main);
}

.eval-nav-btn.active {
    background: rgba(59, 130, 246, 0.12);
    border-color: var(--primary);
    color: white;
    box-shadow: 0 0 12px rgba(59, 130, 246, 0.2);
}

.eval-nav-btn .nav-num {
    font-weight: 700;
    font-size: 0.95rem;
}

.eval-nav-btn .nav-status-icon {
    font-size: 0.9rem;
    transition: transform 0.2s;
}

.eval-nav-btn.correct {
    border-color: var(--success);
    background: rgba(16, 185, 129, 0.05);
    color: var(--success);
}

.eval-nav-btn.correct.active {
    background: rgba(16, 185, 129, 0.15);
    box-shadow: 0 0 12px rgba(16, 185, 129, 0.2);
}

.eval-nav-btn.incorrect {
    border-color: var(--danger);
    background: rgba(239, 68, 68, 0.05);
    color: var(--danger);
}

.eval-nav-btn.incorrect.active {
    background: rgba(239, 68, 68, 0.15);
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.2);
}

/* Panel de Pregunta Activo Derecho */
.evaluation-question-panel {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-height: 280px;
    justify-content: space-between;
    animation: fadeInQuestion 0.3s ease-out;
}

@keyframes fadeInQuestion {
    from {
        opacity: 0;
        transform: translateX(8px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.question-header {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.question-text {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-main);
    line-height: 1.5;
}

.evaluation-feedback-box {
    margin-top: 14px;
    padding: 14px 16px;
    border-radius: 10px;
    font-size: 0.95rem;
    line-height: 1.5;
    animation: slideDownFadeIn 0.3s ease-out forwards;
}

.evaluation-feedback-box.correct {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.25);
    color: var(--text-main);
}

.evaluation-feedback-box.incorrect {
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: var(--text-main);
}

@keyframes slideDownFadeIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.evaluation-submit-final-btn {
    background: linear-gradient(135deg, var(--primary) 0%, #1e40af 100%);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 14px 24px;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
    margin-top: 15px;
    width: 100%;
}

.evaluation-submit-final-btn:hover {
    filter: brightness(1.1);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
}

.evaluation-submit-final-btn:active {
    transform: translateY(0);
}

/* Responsividad para móviles del Cuestionario */
.eval-nav-btn .nav-text {
    display: inline;
}

@media (max-width: 768px) {
    .evaluation-card.multi-question {
        padding: 12px 8px;
        background: transparent;
        border: none;
        box-shadow: none;
    }

    .evaluation-card-header {
        font-size: 0.95rem;
        gap: 8px;
        padding-bottom: 8px;
        margin-bottom: 8px;
    }

    .evaluation-body-grid {
        grid-template-columns: 1fr;
        gap: 16px;
        margin-top: 8px;
    }

    .evaluation-nav-panel {
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        padding-right: 0;
        padding-bottom: 12px;
        gap: 8px;
    }

    .evaluation-nav-dots {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 5px;
        justify-content: center;
    }

    .eval-nav-btn {
        padding: 6px 8px;
        border-radius: 8px;
        flex: 1 1 auto;
        min-width: 38px;
        justify-content: center;
        gap: 4px;
        font-size: 0.85rem;
    }

    .eval-nav-btn .nav-text {
        display: none;
    }

    .eval-nav-btn .nav-status-icon {
        font-size: 0.75rem;
    }

    .question-text {
        font-size: 1rem;
        line-height: 1.4;
    }

    .evaluation-option-label {
        padding: 10px 12px;
        font-size: 0.9rem;
    }
}

/* ===================================
   ESTILOS DE LOGOTIPO RESPONSIVO (TEMA)
   =================================== */
.app-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
}

.app-logo img {
    height: 100%;
    width: auto;
    object-fit: contain;
}

/* Por defecto (tema oscuro): mostrar logo blanco */
.app-logo img.logo-light {
    display: none;
}

.app-logo img.logo-dark {
    display: block;
}

/* Tema claro: mostrar logo azul */
[data-theme="light"] .app-logo img.logo-light {
    display: block;
}

[data-theme="light"] .app-logo img.logo-dark {
    display: none;
}

/* Modificadores de tamaño según contexto */
.mobile-logo {
    height: 30px;
}

.sidebar-logo {
    height: 66px;
    max-width: 100%;
}

.auth-logo {
    height: 60px;
    max-width: 250px;
    margin: 0 auto;
}