/* ==========================================================================
   VAIA App — Global Styles  (unificado · producción)
   --------------------------------------------------------------------------
   Único CSS global de la app. Orden de carga: tabler.min.css → vaia-app.css.

   Principios:
   · Superficies y tema (fondo, texto, bordes) los maneja TABLER (--tblr-*),
     que ya cambia solo entre claro y oscuro. Acá no se redefine ninguna
     superficie: así el dark navy queda coherente.
   · VAIA aporta marca (primario) y forma (radios, sombras, transición) vía
     tokens --vaia-*, más el estilado de componentes compartidos.
   · Cero hex sueltos en componentes: todo por variables.
   ========================================================================== */


/* --------------------------------------------------------------------------
   1. DESIGN TOKENS
   -------------------------------------------------------------------------- */
:root {
    /* Marca — decisión de producto: primario = azul Tabler #0054a6.
       El -rgb DEBE coincidir con el hex (foco/tintes usan este valor). */
    --tblr-primary: #0054a6;
    --tblr-primary-rgb: 0, 84, 166;

    /* Tipografía */
    --tblr-font-sans-serif: 'Inter Var', -apple-system, BlinkMacSystemFont, San Francisco, Segoe UI, Roboto, Helvetica Neue, sans-serif;

    /* Forma */
    --vaia-radius: 12px;
    /* inputs, elementos chicos */
    --vaia-radius-lg: 14px;
    /* cards, modales */
    --vaia-btn-radius: 10px;
    /* botones */

    /* Profundidad (md/lg los usa audioplayer.css — no borrar) */
    --vaia-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.1);
    --vaia-shadow-md: 0 8px 16px rgba(0, 0, 0, 0.06);
    --vaia-shadow-lg: 0 20px 30px rgba(0, 0, 0, 0.08);
    --vaia-shadow-hover: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);

    /* Movimiento */
    --vaia-transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);

    /* Separadores */
    --separator-color: rgba(4, 32, 69, 0.14);
}

[data-bs-theme="dark"] {
    --separator-color: var(--tblr-dark-mode-border-color-translucent);
}


/* --------------------------------------------------------------------------
   2. BASE
   -------------------------------------------------------------------------- */
html {
    scrollbar-gutter: stable;
}

body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    background-color: var(--tblr-body-bg);
    padding-right: 1rem !important;
}

.container-fluid {
    min-width: 99%;
}


/* --------------------------------------------------------------------------
   3. CARDS
   -------------------------------------------------------------------------- */
.card {
    border-radius: var(--vaia-radius-lg);
    box-shadow: var(--vaia-shadow-sm);
    transition: var(--vaia-transition);
}

a.card:hover,
.card-link:hover {
    transform: translateY(-2px);
    box-shadow: var(--vaia-shadow-hover);
}

.card-header {
    background-color: transparent;
    border-bottom: 1px solid rgba(4, 32, 69, 0.05);
    padding: 1.25rem 1.5rem;
}

.card-title {
    font-weight: 600;
    font-size: 1rem;
    letter-spacing: -0.01em;
}

[data-bs-theme="dark"] .card {
    border-color: rgba(255, 255, 255, 0.08);
    box-shadow: none;
}

/* Estado vacío / placeholder con borde punteado */
.card.border-dashed,
.border-dashed {
    border-style: dashed !important;
    border-color: var(--tblr-border-color) !important;
    box-shadow: none;
}


/* --------------------------------------------------------------------------
   4. BOTONES
   -------------------------------------------------------------------------- */
.btn {
    border-radius: var(--vaia-btn-radius);
    transition: var(--vaia-transition);
}

.btn-primary {
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.btn:hover {
    transform: translateY(-1px);
}

.btn-icon {
    width: 2.25rem;
    height: 2.25rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}


/* --------------------------------------------------------------------------
   5. FORMULARIOS  (incluye Tom-Select para que combine)
   -------------------------------------------------------------------------- */
.form-control,
.form-select,
.ts-control {
    border-radius: var(--vaia-radius);
    padding: 0.5rem 0.75rem;
    transition: var(--vaia-transition);
}

.form-control:focus,
.form-select:focus,
.ts-control:focus-within {
    box-shadow: 0 0 0 3px rgba(var(--tblr-primary-rgb), 0.15);
}

/* Formularios generados por Django */
.myTablerForm label {
    font-weight: bold;
    margin-bottom: 2px;
}

.myTablerForm .helptext {
    color: var(--tblr-secondary-color);
    margin-bottom: 3px;
}

.myTablerForm .errorlist {
    color: var(--tblr-danger);
}

/* Checkbox en fila (paneles de filtros) */
.form-check-vaia {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0;
    margin: 0;
    cursor: pointer;
    user-select: none;
}

.form-check-vaia input[type="checkbox"] {
    cursor: pointer;
}

.form-check-vaia span {
    font-weight: 500;
}


/* --------------------------------------------------------------------------
   6. TABLAS
   -------------------------------------------------------------------------- */
.table thead th {
    background-color: #f8fafc;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.04em;
    font-weight: 600;
    color: var(--tblr-secondary);
}

.table tbody td {
    vertical-align: middle;
    padding: 0.75rem 0.75rem;
}

[data-bs-theme="dark"] .table thead th {
    background-color: rgba(0, 0, 0, 0.2);
}

/* Tablas crudas de pandas (reportes: {{ df_table|safe }}) */
.table-responsive .dataframe {
    width: 100%;
    margin: 0;
    border: 0;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.table-responsive .dataframe th,
.table-responsive .dataframe td {
    padding: 0.5rem 0.75rem;
    border: 0;
    border-bottom: 1px solid var(--tblr-border-color);
    white-space: nowrap;
    vertical-align: middle;
}

.table-responsive .dataframe thead th {
    background: var(--tblr-bg-surface-secondary, #f8fafc);
    color: var(--tblr-secondary);
    text-transform: uppercase;
    font-size: 0.72rem;
    letter-spacing: 0.04em;
    font-weight: 600;
    border-bottom: 2px solid var(--tblr-border-color);
    position: sticky;
    top: 0;
    z-index: 1;
}

.table-responsive .dataframe tbody tr:hover {
    background: var(--tblr-bg-surface-secondary, rgba(0, 0, 0, .02));
}


/* --------------------------------------------------------------------------
   7. BADGES
   -------------------------------------------------------------------------- */
.badge {
    border-radius: 4px;
    font-weight: 600;
    letter-spacing: 0.02em;
    padding: 0.35em 0.6em;
}


/* --------------------------------------------------------------------------
   8. PAGE HEADER · SUBHEADER
   -------------------------------------------------------------------------- */
.page-header {
    margin-bottom: 2rem;
}

.page-pretitle {
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.75rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.subheader {
    letter-spacing: 0.06em;
}


/* --------------------------------------------------------------------------
   9. BREADCRUMBS
   -------------------------------------------------------------------------- */
.breadcrumb {
    background: transparent;
    padding: 0;
}

.breadcrumb-item a {
    color: var(--tblr-secondary);
    text-decoration: none;
    transition: color 0.2s;
    display: inline-flex;
    align-items: center;
}

.breadcrumb-item a:hover {
    text-decoration: none;
    transform: translateY(-1px);
}

.breadcrumb-item.active {
    color: var(--tblr-muted);
}

.breadcrumb-arrows a i {
    font-size: 1.1em;
    vertical-align: text-bottom;
    color: var(--tblr-muted);
}

.breadcrumb-arrows a i:hover {
    color: var(--tblr-primary);
}


/* --------------------------------------------------------------------------
   10. NAVEGACIÓN (menú principal + dropdowns) — relocalizado desde menu.html
   -------------------------------------------------------------------------- */
.navbar-nav .nav-link {
    padding: 0.6rem 1rem;
    margin: 0 0.25rem;
    color: var(--tblr-secondary);
    position: relative;
    display: flex;
    align-items: center;
    border-radius: var(--vaia-btn-radius);
}

.nav-link-icon {
    --tblr-icon-size: 1.25rem;
    width: 1.25rem;
    height: 1.25rem;
    font-size: var(--tblr-icon-size);
    vertical-align: bottom;
    stroke-width: 1.5;
    margin-right: 0.5rem;
    margin-bottom: 0.5rem;
    color: inherit;
}

.navbar-nav .nav-link:hover {
    color: var(--tblr-primary);
}

.navbar-nav .nav-link:hover .nav-link-icon {
    opacity: 1;
}

.navbar-nav .nav-item.active .nav-link-icon,
.navbar-nav .nav-item.active .nav-link-title {
    color: var(--tblr-primary);
    opacity: 1;
}

.nav-link-title {
    letter-spacing: -0.01em;
}

.dropdown-toggle::after {
    display: none;
}

.dropdown-toggle-icon {
    margin-top: 0.2rem;
    margin-left: 0.5rem;
    font-size: 0.85rem;
    opacity: 0.5;
}

.dropdown-item {
    color: var(--tblr-secondary);
    border-radius: calc(var(--vaia-btn-radius) - 2px);
    padding: 0.5rem 1rem;
    margin-bottom: 2px;
}

.dropdown-item:hover {
    color: var(--tblr-primary);
}

.dropdown-header {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 700;
    color: var(--tblr-muted);
    padding: 0.5rem 1rem;
    margin-bottom: 0.25rem;
}


/* --------------------------------------------------------------------------
   11. LISTAS ACCIONABLES  (Tabler .list-group-item-actions + toque VAIA)
   -------------------------------------------------------------------------- */
.list-group-item-actions,
.list-group-item-actions:hover {
    text-decoration: none;
}

.list-group-item-actions {
    transition: var(--vaia-transition);
}

.list-group-item-actions:hover {
    background: var(--tblr-bg-surface-secondary, rgba(0, 0, 0, .02));
    box-shadow: inset 2px 0 0 var(--tblr-primary);
}


/* --------------------------------------------------------------------------
   12. FILTROS EN OFFCANVAS  (patrón reusable)
   -------------------------------------------------------------------------- */
.offcanvas-body {
    display: flex;
    flex-direction: column;
}

.offcanvas-filters-content {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

.offcanvas-footer-actions {
    position: sticky;
    bottom: 0;
    background: var(--tblr-body-bg);
    border-top: 1px solid var(--separator-color);
    padding: 1rem 1.5rem;
    margin-top: auto;
    z-index: 10;
}

[data-bs-theme="dark"] .offcanvas-footer-actions {
    background: var(--tblr-dark);
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.2);
}

.filter-badge-count {
    position: absolute;
    top: -6px;
    right: -6px;
    min-width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    border-radius: 10px;
    background: var(--tblr-danger);
    color: #fff;
    border: 2px solid var(--tblr-body-bg);
}

.offcanvas-backdrop {
    background-color: rgba(0, 0, 0, 0.5) !important;
}


/* --------------------------------------------------------------------------
   13. LIBRERÍAS DE TERCEROS  (Litepicker · Tom-Select)
   -------------------------------------------------------------------------- */
/* Litepicker por encima del offcanvas */
.litepicker {
    z-index: 1060 !important;
}

.is-in-range {
    background: #000;
}

body[data-bs-theme="dark"] .litepicker .container__days .day-item.is-in-range {
    background-color: #1e1e1e;
    color: #f0f0f0;
}

/* Tom-Select: evitar el "flash" del <select> nativo antes de inicializar */
select.tom-select {
    opacity: 0;
    pointer-events: none;
    height: 0;
    margin: 0;
    padding: 0;
    border: none;
}

.ts-wrapper {
    visibility: visible;
}

.ts-wrapper:not(.ts-initialized) {
    min-height: 38px;
}


/* --------------------------------------------------------------------------
   14. UTILIDADES VAIA
   -------------------------------------------------------------------------- */
/* Texto truncado a 2 líneas (justificaciones, descripciones) */
.vaia-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}


/* --------------------------------------------------------------------------
   15. MODO OSCURO — ajustes puntuales
   (las superficies las maneja Tabler; acá solo detalles)
   -------------------------------------------------------------------------- */
[data-bs-theme="dark"] ::-webkit-scrollbar-thumb {
    background: #475569;
}


/* --------------------------------------------------------------------------
   16. ACCESIBILIDAD
   -------------------------------------------------------------------------- */
.btn:focus-visible,
.form-control:focus-visible,
.form-select:focus-visible,
.breadcrumb-item a:focus-visible,
.navbar-nav .nav-link:focus-visible,
.dropdown-item:focus-visible {
    outline: 2px solid var(--tblr-primary);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    :root {
        --vaia-transition: none;
    }

    *,
    *::before,
    *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
    }
}
