/* ============================================================
   JAQUE Back Office — Identidad visual (Bootstrap 5 refinement)
   Navy primario · fondos blanco/gris claro · azul refinado
   ============================================================ */
:root {
    --jaque-navy: #16243D;
    --jaque-navy-dark: #0F1A2E;
    --jaque-blue: #2563EB;
    --jaque-blue-hover: #1D4ED8;
    --jaque-bg: #F5F7FA;
    --jaque-surface: #FFFFFF;
    --jaque-border: #E3E8EF;
    --jaque-text: #1F2937;
    --bs-body-bg: var(--jaque-bg);
    --bs-body-color: var(--jaque-text);
    --bs-primary: var(--jaque-navy);
    --bs-link-color: var(--jaque-blue);
    --bs-link-hover-color: var(--jaque-blue-hover);
}

body {
    font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    background: var(--jaque-bg);
    color: var(--jaque-text);
}

h1, h2, h3, h4, h5 {
    color: var(--jaque-navy);
    font-weight: 600;
}

/* ---- Botones refinados ---- */
.btn-primary {
    --bs-btn-bg: var(--jaque-blue);
    --bs-btn-border-color: var(--jaque-blue);
    --bs-btn-hover-bg: var(--jaque-blue-hover);
    --bs-btn-hover-border-color: var(--jaque-blue-hover);
    --bs-btn-active-bg: var(--jaque-blue-hover);
    --bs-btn-active-border-color: var(--jaque-blue-hover);
    --bs-btn-disabled-bg: var(--jaque-blue);
    --bs-btn-disabled-border-color: var(--jaque-blue);
    border-radius: .5rem;
}

.btn-outline-primary {
    --bs-btn-color: var(--jaque-blue);
    --bs-btn-border-color: var(--jaque-blue);
    --bs-btn-hover-bg: var(--jaque-blue);
    --bs-btn-hover-border-color: var(--jaque-blue);
    --bs-btn-active-bg: var(--jaque-blue);
}

/* ---- Tarjetas ---- */
.card {
    border: 1px solid var(--jaque-border);
    border-radius: .75rem;
    box-shadow: 0 1px 2px rgba(22, 36, 61, .06);
}

.card-header {
    background: var(--jaque-surface);
    border-bottom: 1px solid var(--jaque-border);
    font-weight: 600;
    color: var(--jaque-navy);
}

/* ---- Tablas ---- */
.table thead th {
    background: #EEF2F7;
    color: var(--jaque-navy);
    border-bottom: 2px solid var(--jaque-border);
    font-weight: 600;
    white-space: nowrap;
}

.table > :not(caption) > * > * {
    padding: .6rem .75rem;
}

/* ---- Sidebar ---- */
.sidebar {
    background: linear-gradient(180deg, var(--jaque-navy) 0%, var(--jaque-navy-dark) 100%) !important;
}

.sidebar .nav-link {
    border-radius: .4rem;
    margin-bottom: 2px;
}

.sidebar .nav-link:hover {
    background: rgba(255, 255, 255, .08);
}

.sidebar .wordmark {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: .06em;
    color: #FFFFFF;
}

.sidebar .wordmark-sub {
    color: rgba(255, 255, 255, .55);
    font-size: .78rem;
    letter-spacing: .18em;
}

/* ---- Login ---- */
.login-hero {
    min-height: 100vh;
    background: linear-gradient(135deg, var(--jaque-navy) 0%, var(--jaque-navy-dark) 60%, #1E3355 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-card {
    background: var(--jaque-surface);
    border-radius: 1rem;
    box-shadow: 0 12px 40px rgba(0, 0, 0, .35);
    max-width: 420px;
    width: 100%;
}

/* ============================================================
   Shell responsive — sidebar colapsable + header móvil + drawer
   Breakpoints del propietario: escritorio ≥1024 · tablet 768–1023 · móvil <768
   ============================================================ */
:root {
    --sidebar-w: 232px;
    --sidebar-w-collapsed: 74px;
    --mobile-header-h: 56px;
}

.app-shell {
    display: flex;
    min-height: 100vh;
}

/* ---- Sidebar (escritorio: sticky; colapsable; transición suave) ---- */
.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    min-height: 100vh;
    background: linear-gradient(180deg, var(--jaque-navy) 0%, var(--jaque-navy-dark) 100%);
    color: #FFFFFF;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    max-height: 100vh;
    overflow-y: auto;
    transition: width .25s ease, transform .25s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 18px;
    min-height: 40px;
}

.sidebar .wordmark {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: .06em;
    color: #FFFFFF;
    white-space: nowrap;
}

.sidebar .wordmark-sub {
    color: rgba(255, 255, 255, .55);
    font-size: .72rem;
    letter-spacing: .18em;
    white-space: nowrap;
}

.sidebar-collapse-btn {
    background: transparent;
    border: 1px solid rgba(255,255,255,.25);
    color: rgba(255,255,255,.8);
    border-radius: .4rem;
    width: 30px;
    height: 30px;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.sidebar-collapse-btn:hover { background: rgba(255,255,255,.1); color: #fff; }

.sidebar nav { flex: 1 1 auto; }

.sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    color: rgba(255,255,255,.85);
    padding: .62rem .7rem;
    border-radius: .45rem;
    margin-bottom: 2px;
    min-height: 44px;               /* objetivo táctil */
    white-space: nowrap;
}
.sidebar .nav-link:hover,
.sidebar .nav-link:focus-visible { background: rgba(255,255,255,.08); color: #fff; }

.nav-ico {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.nav-label {
    overflow: hidden;
    text-overflow: ellipsis;
    transition: opacity .2s ease;
}

.sidebar-logout { margin-top: auto; padding-top: 12px; }

/* Modo colapsado (solo íconos; tooltip nativo por title/Bootstrap) */
.sidebar.collapsed { width: var(--sidebar-w-collapsed); }
.sidebar.collapsed .nav-label { display: none; }
.sidebar.collapsed .wordmark { font-size: .95rem; letter-spacing: .04em; }
.sidebar.collapsed .sidebar-brand { justify-content: center; }
.sidebar.collapsed .sidebar-collapse-btn { position: static; }
.sidebar.collapsed .nav-link { justify-content: center; padding: .62rem .5rem; }
.sidebar.collapsed .sidebar-logout .btn { padding-left: .5rem; padding-right: .5rem; }

/* ---- Header móvil (<768px) ---- */
.mobile-header {
    display: none;
    align-items: center;
    gap: 12px;
    min-height: var(--mobile-header-h);
    padding: 8px 12px;
    background: linear-gradient(90deg, var(--jaque-navy) 0%, var(--jaque-navy-dark) 100%);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 1030;
}

.hamburger {
    background: transparent;
    border: 1px solid rgba(255,255,255,.25);
    color: #fff;
    border-radius: .45rem;
    width: 44px;                    /* objetivo táctil */
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.hamburger:active { background: rgba(255,255,255,.12); }

.mobile-brand { color: #fff; line-height: 1.1; }
.mobile-brand .fw-bold { font-size: 1.05rem; letter-spacing: .06em; display: block; }
.mobile-brand-sub { font-size: .62rem; letter-spacing: .18em; color: rgba(255,255,255,.6); display: block; }

.mobile-logout {
    background: transparent;
    border: 1px solid rgba(255,255,255,.25);
    color: #fff;
    border-radius: .45rem;
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* ---- Contenido ---- */
.app-main {
    flex: 1 1 auto;
    min-width: 0;                   /* crítico: permite encoger bajo contenido ancho */
    display: flex;
    flex-direction: column;
}

.app-content {
    padding: 24px 28px;
    width: 100%;
}

/* ---- Backdrop del drawer móvil ---- */
.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(16, 29, 50, .55);
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s ease;
    z-index: 1040;
}
.sidebar-backdrop.show { opacity: 1; pointer-events: auto; }

body.drawer-open { overflow: hidden; }   /* bloquea scroll de fondo con drawer abierto */

/* ============================================================
   TABLET (768px–1023px): sidebar por defecto colapsada (la aplica
   site.js al cargar), contenido fluido.
   ============================================================ */
@media (max-width: 1023.98px) {
    .app-content { padding: 20px 20px; }

    /* tablas anchas: desplazamiento horizontal controlado */
    .table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
    }

    .card { margin-bottom: 1rem; }
}

/* ============================================================
   MÓVIL (<768px): sidebar = drawer deslizante desde la izquierda
   ============================================================ */
@media (max-width: 767.98px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        height: 100vh;
        height: 100dvh;             /* altura real del viewport móvil */
        width: min(280px, 84vw);
        transform: translateX(-100%);
        z-index: 1045;
        padding: 16px 12px;
        box-shadow: 0 0 40px rgba(0,0,0,.35);
    }
    .sidebar.drawer-open { transform: translateX(0); }

    .sidebar.collapsed { width: min(280px, 84vw); }   /* en móvil el drawer siempre muestra etiquetas */

    .mobile-header { display: flex; }

    .app-content { padding: 16px 14px; }

    h1 { font-size: 1.35rem; }
    h2 { font-size: 1.15rem; }

    /* formularios a una columna; inputs y selects a todo el ancho */
    .row > [class*="col-"] { flex: 0 0 100%; max-width: 100%; }
    .form-control, .form-select { font-size: 16px; }   /* evita zoom automático iOS */

    /* tarjetas apiladas: ancho fluido */
    .card { width: 100%; }

    /* botones táctiles cómodos */
    .btn { min-height: 40px; }
    .btn-sm { min-height: 36px; }
}

/* ============================================================
   MÓVIL pequeño (<380px)
   ============================================================ */
@media (max-width: 379.98px) {
    .app-content { padding: 12px 10px; }
}

/* ---- Login (layout de autenticación, sin sidebar) ---- */
.auth-body { background: var(--jaque-bg); }

.login-hero {
    min-height: 100vh;
    min-height: 100dvh;
    background: linear-gradient(135deg, var(--jaque-navy) 0%, var(--jaque-navy-dark) 60%, #1E3355 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    overflow-x: hidden;
}

.login-card {
    background: var(--jaque-surface);
    border-radius: 1rem;
    box-shadow: 0 12px 40px rgba(0, 0, 0, .35);
    width: min(420px, 92vw);        /* ~90% del ancho móvil, tope en escritorio */
    margin: 0 auto;
}

/* ---- Impresión de recibos ---- */
@media print {
    .sidebar, .mobile-header, .sidebar-backdrop, .no-print, form, .btn { display: none !important; }
    .app-content { padding: 0 !important; }
    .receipt-block { border: 1px solid #999; }
}
