/* ============================================================
   RESPONSIVE CSS v3.1 — TechSSPTY Nova Design System
   Diseñado para: Móvil (320px+), Tablet (768px+), Desktop (992px+)
   SO compatibles: Android, iOS, Windows, Linux, macOS
   ============================================================ */

/* ═══════════════════════════════════════════════════════════
   1. SIDEBAR COLAPSABLE POR SECCIONES
   ═══════════════════════════════════════════════════════════ */

/* Toggle de sección (encabezado clickable) */
.nav-section-toggle {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.65rem 1.25rem;
    color: rgba(255,255,255,0.45);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    text-decoration: none;
    cursor: pointer;
    transition: color 0.18s, background 0.18s;
    border-left: 3px solid transparent;
    margin-top: 0.25rem;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}
.nav-section-toggle:hover {
    color: rgba(255,255,255,0.75);
    background: rgba(255,255,255,0.04);
    text-decoration: none;
}
.nav-section-toggle .ns-icon {
    width: 16px;
    text-align: center;
    font-size: 0.8rem;
    flex-shrink: 0;
    opacity: 0.7;
}
.nav-section-toggle .ns-arrow {
    margin-left: auto;
    font-size: 0.65rem;
    transition: transform 0.22s ease;
    opacity: 0.5;
}
.nav-section-toggle[aria-expanded="true"] .ns-arrow {
    transform: rotate(90deg);
    opacity: 0.9;
}
.nav-section-toggle[aria-expanded="true"] {
    color: rgba(255,255,255,0.80);
}

/* Sección con hijo activo: borde izquierdo acento */
.sidebar-section.has-active > .nav-section-toggle {
    color: var(--sidebar-active, #00B4D8);
    border-left-color: var(--sidebar-active, #00B4D8);
}

/* Links dentro de sección: pequeña sangría */
.sidebar-section .collapse .nav-link {
    padding-left: 2.25rem;
    font-size: 0.845rem;
}

/* ── Pie de sidebar ─────────────────────────────────────── */
.sidebar-footer {
    border-top: 1px solid rgba(255,255,255,0.07);
    padding: 0.5rem 0;
    flex-shrink: 0;
}
.sidebar-footer .nav-link {
    padding: 0.55rem 1.25rem;
    color: rgba(255,255,255,0.55);
    display: flex;
    align-items: center;
    gap: 0.65rem;
    font-size: 0.875rem;
    transition: color 0.18s, background 0.18s;
    text-decoration: none;
    border-left: 3px solid transparent;
}
.sidebar-footer .nav-link:hover { color: rgba(255,255,255,0.9); background: rgba(255,255,255,0.05); }
.sidebar-footer .nav-link-logout { color: rgba(252,129,129,0.75); }
.sidebar-footer .nav-link-logout:hover { color: #fc8181; background: rgba(220,53,69,0.12); }
.sidebar-footer .nav-link i { width: 18px; text-align: center; flex-shrink: 0; }

/* ── Usuario compacto en sidebar (móvil) ────────────────── */
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.75rem 1.1rem;
    border-bottom: 1px solid rgba(255,255,255,0.07);
    background: rgba(0,0,0,0.15);
}
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name { font-size: 0.82rem; font-weight: 600; color: rgba(255,255,255,0.9); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: 0.68rem; color: rgba(255,255,255,0.45); }
.sidebar-user-logout {
    color: rgba(252,129,129,0.7);
    font-size: 1rem;
    padding: 0.25rem;
    border-radius: 6px;
    transition: color 0.18s, background 0.18s;
    -webkit-tap-highlight-color: transparent;
}
.sidebar-user-logout:hover { color: #fc8181; background: rgba(220,53,69,0.15); }

/* ── Logo fallback ──────────────────────────────────────── */
.sidebar-brand-fallback {
    color: #fff;
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: 0.5px;
    gap: 0.5rem;
    align-items: center;
}
.sidebar-brand-fallback i { font-size: 1.4rem; color: #00B4D8; }

/* ═══════════════════════════════════════════════════════════
   2. LAYOUT BASE — shared across breakpoints
   ═══════════════════════════════════════════════════════════ */

/* Tabla responsive: scroll horizontal con aceleración GPU en iOS */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
}

/* Contenedores: padding base */
.container-fluid {
    padding-left: 1.25rem;
    padding-right: 1.25rem;
}

/* Mejor font-rendering en todos los OS */
body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* Touch: quitar resaltado azul en Android/Chrome */
a, button, [role="button"] {
    -webkit-tap-highlight-color: transparent;
}

/* Touch targets mínimos — WCAG 2.5.5 (44×44px) */
.btn, .nav-link, .btn-action, .dropdown-item {
    min-height: 36px;
}
@media (hover: none) and (pointer: coarse) {
    .btn, .nav-link, .dropdown-item {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    .btn-action {
        min-width: 38px;
        min-height: 38px;
    }
}

/* ═══════════════════════════════════════════════════════════
   3. DESKTOP ANCHO (≥1400px)
   ═══════════════════════════════════════════════════════════ */
@media (min-width: 1400px) {
    .nova-content { padding: 1.75rem 2rem; }
}

/* ═══════════════════════════════════════════════════════════
   4. TABLET GRANDE / LAPTOP PEQUEÑO (992px – 1199px)
   ═══════════════════════════════════════════════════════════ */
@media (min-width: 992px) and (max-width: 1199px) {
    :root { --nova-sidebar-width: 230px; }
    .sidebar-nav .nav-link { font-size: 0.835rem; }
    .kpi-value { font-size: 1.5rem !important; }
}

/* ═══════════════════════════════════════════════════════════
   5. TABLET + MÓVIL (< 992px)
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 991.98px) {

    /* ── Sidebar: oculto por defecto, desliza desde la izquierda ── */
    .nova-sidebar {
        transform: translateX(-100%);
        width: 270px !important;
        box-shadow: none;
    }
    .nova-sidebar.show {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0,0,0,0.35);
    }

    /* Header: ocupa todo el ancho */
    .nova-header { left: 0 !important; }

    /* Contenido: sin margen izquierdo del sidebar */
    .nova-content {
        margin-left: 0 !important;
        padding: 1rem;
    }
    .nova-footer { margin-left: 0 !important; }

    /* Overlay semitransparente al abrir sidebar */
    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.5);
        backdrop-filter: blur(3px);
        -webkit-backdrop-filter: blur(3px);
        z-index: 1039;
        transition: opacity 0.25s;
    }
    .sidebar-overlay.active { display: block; }
    .sidebar-open .sidebar-overlay { display: block; }
    .sidebar-open .nova-sidebar { transform: translateX(0); }

    /* Page headers: apilar verticalmente */
    .page-header {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 0.75rem;
    }
    .page-header-actions { width: 100%; }
    .page-header-actions .btn { flex: 1 1 auto; text-align: center; }

    /* Filter bars: stack */
    .filter-bar .row > [class*="col-"] {
        flex: 0 0 100%;
        max-width: 100%;
    }
    .filter-bar form.row { gap: 0.5rem; }

    /* Modales: usar casi toda la pantalla */
    .modal-dialog { max-width: 95vw !important; margin: 0.5rem auto; }

    /* Tables: ocultar columnas secundarias */
    .table .d-none-mobile { display: none !important; }

    /* KPI cards: 2 columnas */
    .col-xl-3.col-6, .col-md-3 { flex: 0 0 50%; max-width: 50%; }
}

/* ═══════════════════════════════════════════════════════════
   6. TABLET MEDIANO (576px – 767px)
   ═══════════════════════════════════════════════════════════ */
@media (min-width: 576px) and (max-width: 767.98px) {
    .container-fluid { padding-left: 1rem; padding-right: 1rem; }
    .kpi-value { font-size: 1.4rem !important; }
}

/* ═══════════════════════════════════════════════════════════
   7. MÓVIL (< 576px)
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 575.98px) {

    /* Padding global más estrecho */
    .container-fluid { padding-left: 0.75rem; padding-right: 0.75rem; }
    .nova-content { padding: 0.75rem; }

    /* KPI cards: 1 columna en pantallas muy pequeñas */
    .col-6.col-xl-3,
    .col-6.col-md-3,
    .col-6.col-md-4,
    .col-md-3, .col-md-4 {
        flex: 0 0 50%;
        max-width: 50%;
    }

    /* Stat/KPI: font más pequeño */
    .kpi-value { font-size: 1.25rem !important; }
    .kpi-label { font-size: 0.72rem !important; }
    .kpi-footer { font-size: 0.68rem !important; }

    /* Botones en page-header: texto reducido */
    .page-header-actions .btn { font-size: 0.78rem; padding: 0.35rem 0.65rem; }

    /* Títulos */
    h4 { font-size: 1.1rem !important; }
    h5 { font-size: 1rem !important; }

    /* Tablas: texto más pequeño, celdas compactas */
    .table { font-size: 0.78rem; }
    .table thead th { padding: 0.55rem 0.6rem; font-size: 0.68rem; }
    .table td { padding: 0.55rem 0.6rem; }

    /* Acciones: icono sin texto */
    .btn-action { min-width: 34px; min-height: 34px; }

    /* Modales: pantalla completa */
    .modal-dialog { margin: 0 !important; max-width: 100vw !important; min-height: 100dvh; }
    .modal-content { border-radius: 0; min-height: 100dvh; }

    /* Cards: sin padding lateral excesivo */
    .card-body { padding: 0.9rem; }

    /* Formularios: inputs a ancho completo */
    .filter-bar .btn { width: 100%; }

    /* Nav tabs: scroll horizontal */
    .nav-tabs { flex-wrap: nowrap; overflow-x: auto; white-space: nowrap; }
    .nav-tabs .nav-item { flex-shrink: 0; }

    /* Sidebar usuario compacto visible */
    .sidebar-user { display: flex !important; }

    /* Badges de estado: más pequeños */
    .badge { font-size: 0.66rem; padding: 0.2em 0.45em; }

    /* Progreso: texto compacto */
    .progress { height: 6px !important; }
}

/* ═══════════════════════════════════════════════════════════
   8. ORIENTACIÓN LANDSCAPE EN MÓVIL
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 767.98px) and (orientation: landscape) {
    .nova-content { padding-top: 0.6rem; }
    .modal-content { border-radius: var(--nova-radius); }
    .modal-dialog { min-height: auto; margin: 0.5rem auto; }
}

/* ═══════════════════════════════════════════════════════════
   9. MODO OSCURO — ajustes responsivos
   ═══════════════════════════════════════════════════════════ */
[data-theme="dark"] .filter-bar {
    background: var(--nova-card-bg);
    border-color: var(--nova-border);
}
[data-theme="dark"] .table-danger {
    --bs-table-bg: rgba(220,53,69,0.12);
    --bs-table-color: var(--nova-text);
}
[data-theme="dark"] .table-warning {
    --bs-table-bg: rgba(245,158,11,0.12);
    --bs-table-color: var(--nova-text);
}
[data-theme="dark"] .card-header.bg-white {
    background: var(--nova-card-bg) !important;
}

/* ═══════════════════════════════════════════════════════════
   10. IMPRESIÓN
   ═══════════════════════════════════════════════════════════ */
@media print {
    .nova-sidebar,
    .nova-header,
    .nova-footer,
    .sidebar-overlay,
    .btn:not(.btn-print),
    .page-header-actions,
    .filter-bar,
    .modal { display: none !important; }

    .nova-content {
        margin: 0 !important;
        padding: 0 !important;
    }
    .card { box-shadow: none !important; border: 1px solid #ddd !important; }
    body { background: #fff !important; color: #000 !important; }
    a { color: inherit !important; text-decoration: none !important; }
    .table { border-collapse: collapse !important; }
    .table td, .table th { border: 1px solid #ccc !important; }
}

/* ═══════════════════════════════════════════════════════════
   11. HOVER: desactivar animaciones en touch
   ═══════════════════════════════════════════════════════════ */
@media (hover: none) {
    .hover-lift:hover {
        transform: none !important;
        box-shadow: var(--nova-shadow) !important;
    }
    .stat-card:hover { transform: none; box-shadow: var(--nova-shadow); }
}

/* ═══════════════════════════════════════════════════════════
   12. ACCESIBILIDAD — Reducir movimiento (prefers-reduced-motion)
   ═══════════════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ═══════════════════════════════════════════════════════════
   13. UTILIDADES RESPONSIVE ADICIONALES
   ═══════════════════════════════════════════════════════════ */

/* Scroll horizontal suave en tablas */
.table-scroll-x {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Sticky primera columna en tablas móvil */
@media (max-width: 767.98px) {
    .table-sticky-first th:first-child,
    .table-sticky-first td:first-child {
        position: sticky;
        left: 0;
        background: var(--nova-card-bg);
        z-index: 1;
        box-shadow: 2px 0 4px rgba(0,0,0,0.05);
    }
}

/* Page-header: alinear acciones a la derecha en desktop, full en móvil */
.page-header-right {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}
@media (max-width: 575.98px) {
    .page-header-right { width: 100%; }
    .page-header-right .btn { flex: 1; }
}

/* Breakpoints de utilidad personalizados */
.d-none-mobile  { } /* marcar columnas a ocultar en móvil (ver arriba) */
.d-xs-none { }      /* usar con @media max-width: 575px */
