/* ============================================
   VARIABLES Y DARK MODE
   ============================================ */
:root {
    --accent: #1e3a5f;
    --accent-dark: #152c47;
    --accent-rgb: 30, 58, 95;
    --nav-indicator: #10b981;
}

html.dark {
    --nav-indicator: #34d399;
}

/* Dark Mode */
html.dark body {
    background-color: #0f172a;
    color: #f1f5f9;
}

html.dark aside {
    background-color: #1e293b !important;
    border-color: #334155 !important;
}

html.dark header {
    background-color: #1e293b !important;
    border-color: #334155 !important;
}

html.dark main,
html.dark section[id$="Panel"] {
    background-color: #0f172a;
}

html.dark #settingsPanel {
    background-color: #0f172a;
}

html.dark h1,
html.dark h2,
html.dark h3,
html.dark p.text-gray-900 {
    color: #ffffff !important;
}

html.dark .text-gray-900 {
    color: #ffffff !important;
}

html.dark .text-gray-800 {
    color: #f1f5f9 !important;
}

html.dark .text-gray-700 {
    color: #e2e8f0 !important;
}

html.dark .text-gray-600 {
    color: #cbd5e1 !important;
}

html.dark .text-gray-500 {
    color: #94a3b8 !important;
}

html.dark .text-gray-400 {
    color: #94a3b8 !important;
}

/* Improved contrast from 64748b */
html.dark .bg-white {
    background-color: #1e293b !important;
}

html.dark .bg-gray-50\/50 {
    background-color: #0f172a !important;
}

html.dark .bg-gray-100 {
    background-color: #1e293b !important;
}

html.dark .border-gray-100 {
    border-color: #334155 !important;
}

html.dark .border-gray-200 {
    border-color: #334155 !important;
}

html.dark .divide-gray-50>* {
    border-color: #334155 !important;
}

html.dark .bg-gray-50 {
    background-color: #0f172a !important;
}

/* Configuración Panel - Dark Mode Overrides */
html.dark #settingsPanel h2 {
    font-weight: 700 !important;
    font-size: 16px !important;
    color: #ffffff !important;
}

html.dark #settingsPanel p.font-medium {
    font-weight: 600 !important;
    font-size: 14px !important;
    color: #e2e8f0 !important;
}

html.dark #settingsPanel p.font-light {
    font-weight: 400 !important;
    font-size: 12px !important;
    color: #94a3b8 !important;
}

html.dark #settingsPanel .px-6.py-4 i[data-lucide] {
    color: #10b981 !important;
}

html.dark #settingsPanel .bg-green-50 {
    background-color: #064e3b !important;
    color: #34d399 !important;
    border-color: #10b981 !important;
}

html.dark #settingsPanel .bg-green-500 {
    background-color: #34d399 !important;
}

html.dark #darkModeToggle[aria-checked="true"] {
    background-color: #10b981 !important;
}

html.dark #settingsPanel .p-6 {
    padding: 24px !important;
}

html.dark #settingsPanel .space-y-5>*:not(:last-child) {
    border-bottom: 1px solid #334155;
    padding-bottom: 20px;
    margin-bottom: 20px;
}

html.dark #settingsPanel .space-y-5>* {
    margin-top: 0 !important;
}

/* Sidebar Active Item in Dark Mode */
html.dark nav a.bg-\[\#1e3a5f\]\/5 {
    background-color: #1e293b !important;
    border-radius: 0 8px 8px 0;
    color: #f1f5f9 !important;
}

html.dark nav a.bg-\[\#1e3a5f\]\/5 i {
    color: #10b981 !important;
}

/* Nuevo Cliente Modal - Light Mode Override */
html:not(.dark) #addClientModal>div {
    background-color: #ffffff !important;
    border: 1px solid #e5e7eb !important;
}

html:not(.dark) #addClientModal .modal-overlay {
    background-color: rgba(0, 0, 0, 0.4) !important;
}

html:not(.dark) #addClientModal h3 {
    color: #111827 !important;
}

html:not(.dark) #addClientModal label {
    color: #374151 !important;
}

html:not(.dark) #addClientModal input,
html:not(.dark) #addClientModal select {
    background-color: #f9fafb !important;
    border: 1px solid #d1d5db !important;
    color: #111827 !important;
}

html:not(.dark) #addClientModal input::placeholder {
    color: #9ca3af !important;
}

html:not(.dark) #addClientModal input:focus,
html:not(.dark) #addClientModal select:focus {
    border: 1px solid #10b981 !important;
}

html:not(.dark) #addClientModal h3 span {
    background-color: rgba(16, 185, 129, 0.10) !important;
}

html:not(.dark) #addClientModal h3 i {
    color: #10b981 !important;
}

/* Nuevo Cliente Modal - Dark Mode */
html.dark #addClientModal>div {
    background-color: #1e293b !important;
    border: 1px solid #334155 !important;
    border-radius: 16px !important;
}

html.dark #addClientModal .modal-overlay {
    background-color: rgba(0, 0, 0, 0.6) !important;
}

html.dark #addClientModal .sticky.top-0 {
    background-color: #1e293b !important;
    border-bottom: 1px solid #334155 !important;
}

html.dark #addClientModal .sticky.top-0 h2 {
    color: #ffffff !important;
    font-size: 18px !important;
    font-weight: 700 !important;
}

html.dark #addClientModal #closeClientModal {
    color: #64748b !important;
}

html.dark #addClientModal #closeClientModal:hover {
    color: #f1f5f9 !important;
    background-color: transparent !important;
}

html.dark #addClientModal label {
    color: #cbd5e1 !important;
    font-size: 12px !important;
    font-weight: 500 !important;
    margin-bottom: 6px !important;
}

html.dark #addClientModal input,
html.dark #addClientModal select {
    background-color: #0f172a !important;
    border: 1px solid #334155 !important;
    color: #f1f5f9 !important;
    border-radius: 8px !important;
    padding: 10px 14px !important;
    font-size: 14px !important;
    box-shadow: none !important;
}

html.dark #addClientModal input:focus,
html.dark #addClientModal select:focus {
    border: 1px solid #10b981 !important;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15) !important;
    outline: none !important;
}

html.dark #addClientModal input::placeholder {
    color: #64748b !important;
}

/* Nuevo Cliente Modal - Footer Botones Dark Mode */
html.dark #addClientModal form>div:last-child {
    display: flex !important;
    justify-content: flex-end !important;
    gap: 12px !important;
    padding-top: 20px !important;
    border-top: 1px solid #1e293b !important;
}

html.dark #addClientModal #cancelClientBtn {
    background-color: transparent !important;
    border: 1px solid #475569 !important;
    color: #94a3b8 !important;
    border-radius: 8px !important;
    padding: 10px 20px !important;
    font-weight: 500 !important;
    font-size: 14px !important;
    transition: all 0.2s ease !important;
}

html.dark #addClientModal #cancelClientBtn:hover {
    border-color: #94a3b8 !important;
    color: #f1f5f9 !important;
    background-color: transparent !important;
}

html.dark #addClientModal button[type="submit"] {
    background-color: #10b981 !important;
    border: none !important;
    color: #ffffff !important;
    border-radius: 8px !important;
    padding: 10px 20px !important;
    font-weight: 600 !important;
    font-size: 14px !important;
    transition: all 0.2s ease !important;
    cursor: pointer !important;
    box-shadow: none !important;
}

html.dark #addClientModal button[type="submit"]:hover {
    background-color: #059669 !important;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.35) !important;
}

html.dark input,
html.dark select,
html.dark textarea {
    background-color: #1e293b !important;
    border-color: #334155 !important;
    color: #e2e8f0 !important;
}

html.dark input::placeholder {
    color: #94a3b8 !important;
}

html.dark .table-row-hover:hover {
    background-color: #1e293b !important;
}

html.dark .hover\:bg-gray-50:hover {
    background-color: #1e293b !important;
}

html.dark .hover\:bg-gray-100:hover {
    background-color: #334155 !important;
}

html.dark .rounded-lg.border {
    border-color: #334155 !important;
}

html.dark .shadow-sm {
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.4) !important;
}

html.dark .modal-overlay {
    background-color: rgba(0, 0, 0, 0.6) !important;
}

html.dark .bg-\[\#1e3a5f\]\/5 {
    background-color: rgba(var(--accent-rgb), 0.15) !important;
}

/* Accent color variable */
.accent-dynamic {
    background-color: var(--accent) !important;
}

.accent-dynamic:hover {
    background-color: var(--accent-dark) !important;
}

body {
    background-color: #fafafa;
}

* {
    font-family: 'Inter', sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

:focus-visible {
    outline: 2px solid #1e3a5f;
    outline-offset: 2px;
}



/* Clases de Utilidad y Componentes (ExportPro) */
.accent-border {
    border-left: 3px solid #1e3a5f;
}

.accent-bg {
    background-color: #1e3a5f;
}

.accent-text {
    color: #1e3a5f;
}

.accent-hover:hover {
    background-color: #152c47;
}

.card-hover {
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.card-hover:hover {
    border-color: #e5e7eb;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    transform: translateY(-1px);
}

.table-row-hover:hover {
    background-color: #f9fafb;
}

.modal-overlay {
    background-color: rgba(0, 0, 0, 0.3);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
}

.tab-active {
    border-bottom: 4px solid #1e3a5f;
    color: #111827;
    background-color: #f3f4f6;
    font-weight: 800;
    border-top-left-radius: 0.5rem;
    border-top-right-radius: 0.5rem;
}

.drag-zone {
    border: 2px dashed #e5e7eb;
    transition: all 0.3s ease;
}

.drag-zone:hover,
.drag-zone.drag-over {
    border-color: #1e3a5f;
    background-color: #f0f4f8;
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

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

::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Estilo personalizado para selects */
select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.7rem center;
    background-size: 1em;
    padding-right: 2.5rem;
}

/* Tooltip personalizado */
[data-tooltip] {
    position: relative;
}

[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 5px);
    left: 50%;
    transform: translateX(-50%);
    padding: 4px 8px;
    background: #1f2937;
    color: white;
    font-size: 12px;
    border-radius: 4px;
    white-space: nowrap;
    z-index: 100;
    pointer-events: none;
}

/* Animaciones */
@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

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

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }

    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

.toast-enter {
    animation: slideIn 0.3s ease forwards;
}

.toast-exit {
    animation: slideOut 0.3s ease forwards;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

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

#clientsTableBody tr {
    animation: fadeInUp 0.3s ease forwards;
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

.loading-shimmer {
    animation: shimmer 0.9s infinite linear;
    background: linear-gradient(
        105deg,
        #d1d5db 0%,
        #d1d5db 25%,
        #f3f4f6 37%,
        #ffffff 45%,
        #f3f4f6 53%,
        #d1d5db 65%,
        #d1d5db 100%
    );
    background-size: 200% 100%;
}

/* ── Dark mode skeleton ── */
html.dark .loading-shimmer {
    background: linear-gradient(
        105deg,
        #1e293b 0%,
        #1e293b 25%,
        #334155 37%,
        #475569 45%,
        #334155 53%,
        #1e293b 65%,
        #1e293b 100%
    );
    background-size: 200% 100%;
}

/* ============================================
   UTILIDADES DE ICONOS (Migrados desde inline styles)
   ============================================ */
.icon-box-green {
    background-color: rgba(16, 185, 129, 0.12);
    padding: 5px;
}

.icon-green-sm {
    width: 14px;
    height: 14px;
    stroke-width: 1.5;
    color: #10B981;
}

/* ============================================
   GESTIÓN DE USUARIOS - Dark Mode
   ============================================ */
html.dark #userManagementSection {
    background-color: #1e293b !important;
    border-color: #334155 !important;
}

html.dark #userManagementSection h2 {
    color: #ffffff !important;
    font-weight: 700 !important;
}

html.dark #userManagementSection .bg-blue-50 {
    background-color: rgba(30, 58, 95, 0.5) !important;
    color: #93c5fd !important;
    border-color: #2563eb !important;
}

html.dark #userManagementSection .bg-gray-100 {
    background-color: #334155 !important;
    color: #e2e8f0 !important;
    border-color: #475569 !important;
}

html.dark #userManagementSection .bg-green-50 {
    background-color: #064e3b !important;
    color: #34d399 !important;
    border-color: #10b981 !important;
}

html.dark #userManagementSection .bg-red-50 {
    background-color: #7f1d1d !important;
    color: #fca5a5 !important;
    border-color: #ef4444 !important;
}

html.dark #inviteFormContainer {
    background-color: rgba(0, 0, 0, 0.6) !important;
}

html.dark #inviteFormContainer label {
    color: #cbd5e1 !important;
}

html.dark #userManagementSection #toggleInviteForm {
    background-color: #1e3a5f !important;
}

html.dark #userManagementSection #toggleInviteForm:hover {
    background-color: #152c47 !important;
}

/* ============================================
   PREFERENCIAS: TAMAÑO DE TEXTO Y DENSIDAD
   ============================================ */
html.text-size-large {
    font-size: 18px;
}

html.density-compact table tbody>tr>td,
html.density-compact table tbody>tr>th {
    padding-top: 0.4rem;
    padding-bottom: 0.4rem;
}

html.density-compact table thead>tr>th {
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
}

/* ============================================
   LAYOUT DASHBOARD — Una sola vista visible a la vez
   ============================================
   #dashboardView es un contenedor flex cuyos hijos son los paneles
   (main/section con flex-1 ml-64). Si dos paneles quedaran visibles,
   el flex los acomoda lado a lado (efecto "dos columnas").
   Forzamos display:none !important en cualquier panel con .hidden
   para garantizar que solo el panel activo (sin .hidden) renderice.
   El sidebar <aside> es position:fixed y queda fuera de este flujo. */
#dashboardView > main.hidden,
#dashboardView > section.hidden {
    display: none !important;
}

/* ============================================
   MOBILE RESPONSIVE — breakpoint 768px
   ============================================ */
@media (max-width: 767px) {
    /* Sidebar: oculto por defecto, se desliza como overlay */
    #dashboardView > aside {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    #dashboardView > aside.mobile-open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0,0,0,0.15);
    }

    /* Mostrar botón hamburguesa */
    #mobileMenuBtn {
        display: flex !important;
    }

    /* Quitar margin-left de los paneles principales */
    #dashboardView > main,
    #dashboardView > section {
        margin-left: 0 !important;
        width: 100% !important;
    }

    /* Ajustar padding del contenido */
    .pt-12.px-8.pb-8,
    .p-8 {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
    header.px-8 {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }

    /* Filtros y búsqueda: full width en mobile */
    header input[type="text"],
    header input[type="search"],
    header .relative {
        width: 100% !important;
    }
    header .lg\:ml-auto {
        margin-left: 0 !important;
    }

    /* KPIs: 2 columnas en vez de 3-4 */
    #dashboardView .grid-cols-4,
    #dashboardView .md\:grid-cols-4 {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    #dashboardView .md\:grid-cols-3 {
        grid-template-columns: repeat(2, 1fr) !important;
    }


    /* Títulos de header más compactos en mobile */
    header h2 {
        font-size: 1.1rem !important;
    }
    header p.text-sm {
        font-size: 0.8rem !important;
    }

    /* Ajuste del header para no quedar detrás del botón hamburguesa */
    #dashboardView header.sticky {
        padding-left: 3.5rem !important;
    }
}

/* ── Indicador de navegación activa ── */
#navActiveIndicator {
    position: absolute;
    left: 10px;
    width: 2px;
    background-color: var(--nav-indicator);
    transition: none;
    border-radius: 0 2px 2px 0;
    pointer-events: none;
    z-index: 10;
    opacity: 0;
    will-change: top, height;
}

#navActiveIndicator.ready {
    transition: top 0.25s cubic-bezier(0.4,0,0.2,1), height 0.25s cubic-bezier(0.4,0,0.2,1);
}

/* ── Utilidades Adicionales ── */
.sidebar-header {
    min-height: 82px;
}

.toast-transition {
    transition: opacity .25s ease, transform .25s ease;
}

/* ── Panel de Ayuda ── */

/* FAQ Acordeón */
#helpPanel .help-faq-item {
    overflow: hidden;
}

#helpPanel .help-faq-btn {
    outline: none;
}

#helpPanel .help-faq-content {
    transition: max-height 0.25s ease-in-out;
}

#helpPanel .help-faq-item.open .help-faq-btn {
    background-color: rgba(30, 58, 95, 0.04);
}

html.dark #helpPanel .help-faq-item.open .help-faq-btn {
    background-color: rgba(59, 130, 246, 0.08);
}

/* Category Cards */
#helpPanel .help-category-card {
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
}

#helpPanel .help-category-card:hover {
    transform: translateY(-1px);
}

#helpPanel .help-category-link {
    text-decoration: none;
    color: inherit;
}

/* Search focus ring */
#helpPanel #helpSearchInput:focus {
    box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.1);
}

/* Modal Añadir Usuario - Dark Mode Icon Header */
html.dark #inviteFormContainer span.w-8.h-8.rounded-full {
    background-color: rgba(255, 255, 255, 0.15) !important;
    color: #ffffff !important;
}

html.dark #inviteFormContainer span.w-8.h-8.rounded-full [data-lucide],
html.dark #inviteFormContainer span.w-8.h-8.rounded-full svg {
    color: #ffffff !important;
    stroke: #ffffff !important;
}

/* Modal Editar Usuario - Dark Mode Icon Header */
html.dark #editUserModal span.w-8.h-8.rounded-full {
    background-color: rgba(255, 255, 255, 0.15) !important;
    color: #ffffff !important;
}

html.dark #editUserModal span.w-8.h-8.rounded-full [data-lucide],
html.dark #editUserModal span.w-8.h-8.rounded-full svg {
    color: #ffffff !important;
    stroke: #ffffff !important;
}