/* VM Seguridad — Estilos responsive (mobile-first) */
:root {
    --gg-sidebar-width: 260px;
    --gg-sidebar-bg: #1a1c23;
    --gg-sidebar-hover: rgba(255, 255, 255, 0.08);
    --gg-sidebar-active: rgba(78, 115, 223, 0.25);
    --gg-accent: #4e73df;
    --gg-success: #1cc88a;
    --gg-danger: #e74a3b;
    --gg-warning: #f6c23e;
    --gg-body-bg: #f4f6f9;
}

/* ─── Base ─────────────────────────────────────────────────── */
body.app-body {
    font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background-color: var(--gg-body-bg);
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

/* ─── Navbar ───────────────────────────────────────────────── */
.navbar {
    padding-top: 0.4rem;
    padding-bottom: 0.4rem;
    z-index: 1040;
}

.navbar-brand {
    font-size: 1rem;
}

@media (max-width: 575.98px) {
    .navbar-brand {
        font-size: 0.9rem;
    }
}

/* ─── Sidebar ──────────────────────────────────────────────── */
.sidebar-offcanvas {
    background-color: var(--gg-sidebar-bg) !important;
}

.sidebar-link {
    color: rgba(255, 255, 255, 0.72);
    text-decoration: none;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
    font-size: 0.9rem;
    min-height: 44px;
    display: flex;
    align-items: center;
}

.sidebar-link:hover,
.sidebar-link:focus {
    color: #fff;
    background-color: var(--gg-sidebar-hover);
    border-left-color: rgba(255, 255, 255, 0.3);
}

.sidebar-link.active {
    color: #fff;
    background-color: var(--gg-sidebar-active);
    border-left-color: var(--gg-accent);
    font-weight: 600;
}

.sidebar-link i {
    opacity: 0.7;
    transition: opacity 0.2s;
}

.sidebar-link:hover i,
.sidebar-link.active i {
    opacity: 1;
}

@media (min-width: 992px) {
    .sidebar-offcanvas.offcanvas-lg {
        position: relative;
        transform: none !important;
        visibility: visible !important;
        width: var(--gg-sidebar-width);
        max-width: var(--gg-sidebar-width);
        flex-shrink: 0;
        height: auto;
        border-right: 1px solid rgba(255, 255, 255, 0.08);
    }

    .sidebar-offcanvas.offcanvas-lg .offcanvas-header {
        display: none;
    }
}

/* ─── Main Content ─────────────────────────────────────────── */
.main-content {
    min-height: calc(100vh - 120px);
    padding: 1rem !important;
}

@media (min-width: 992px) {
    .main-content {
        padding: 1.5rem !important;
    }
}

/* ─── Cards ────────────────────────────────────────────────── */
.card {
    border-radius: 0.625rem;
    transition: box-shadow 0.2s ease;
    overflow: hidden;
}

.card:hover {
    box-shadow: 0 0.25rem 1rem rgba(0, 0, 0, 0.08) !important;
}

.stat-card {
    border-left: 4px solid;
}

.stat-card.border-primary { border-left-color: var(--gg-accent) !important; }
.stat-card.border-success { border-left-color: var(--gg-success) !important; }
.stat-card.border-warning { border-left-color: var(--gg-warning) !important; }
.stat-card.border-danger { border-left-color: var(--gg-danger) !important; }

/* ─── Tables ───────────────────────────────────────────────── */
.table th {
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #6c757d;
}

.table td {
    vertical-align: middle;
    font-size: 0.88rem;
}

.table-hover tbody tr:hover {
    background-color: rgba(78, 115, 223, 0.04);
}

.table-responsive {
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 767.98px) {
    .table th,
    .table td {
        font-size: 0.78rem;
        padding: 0.4rem 0.5rem;
    }

    .table .btn-sm {
        padding: 0.2rem 0.4rem;
        font-size: 0.7rem;
    }
}

/* ─── Forms ────────────────────────────────────────────────── */
.form-control,
.form-select {
    min-height: 44px;
    font-size: 1rem;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--gg-accent);
    box-shadow: 0 0 0 0.2rem rgba(78, 115, 223, 0.25);
}

@media (min-width: 992px) {
    .form-control,
    .form-select {
        min-height: 38px;
        font-size: 0.9rem;
    }
}

/* ─── Buttons ──────────────────────────────────────────────── */
.btn {
    border-radius: 0.375rem;
    font-weight: 500;
    transition: all 0.2s ease;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-sm {
    min-height: 34px;
    font-size: 0.82rem;
}

@media (min-width: 992px) {
    .btn {
        min-height: auto;
    }
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}

.btn:active {
    transform: translateY(0);
}

/* ─── Login Page ───────────────────────────────────────────── */
body.login-page {
    font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    min-height: 100vh;
    min-height: -webkit-fill-available;
    background: linear-gradient(135deg, #4e73df 0%, #224abe 100%);
}

.login-card {
    border: none;
    border-radius: 1rem;
    box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.25);
}

.login-brand {
    width: 4rem;
    height: 4rem;
    border-radius: 1rem;
    background: linear-gradient(135deg, #4e73df, #224abe);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    margin: 0 auto 1rem;
}

/* ─── Matrix / Turnos ──────────────────────────────────────── */
.matrix-table {
    font-size: 0.82rem;
    table-layout: fixed;
    width: 100%;
}

.matrix-table th,
.matrix-table td {
    vertical-align: middle;
    overflow: hidden;
    text-overflow: ellipsis;
}

.matrix-table .col-info {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.78rem;
}

.matrix-table .col-dia {
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    text-align: center;
    white-space: nowrap;
}

.matrix-table thead .col-dia {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.25rem 0.1rem;
    letter-spacing: 0;
    line-height: 1.2;
}

.dia-header-nombre {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    line-height: 1.1;
}

.dia-header-fecha {
    font-size: 0.65rem;
    font-weight: 500;
    color: #6c757d;
    line-height: 1.1;
    margin-top: 1px;
}

.shift-D {
    background-color: #198754 !important;
    color: #fff !important;
}

.shift-N {
    background-color: #0d6efd !important;
    color: #fff !important;
}

.shift-L {
    background-color: #dc3545 !important;
    color: #fff !important;
}

.turno-cell {
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 700;
    transition: opacity 0.15s;
    -webkit-user-select: none;
    user-select: none;
    padding: 0.25rem 0 !important;
    line-height: 1.5;
}

.turno-cell:hover {
    opacity: 0.8;
    outline: 2px solid #333;
    outline-offset: -2px;
}

.hoy-cell {
    outline: 2px solid var(--gg-warning);
    outline-offset: -2px;
}

.retiro-indicator {
    position: absolute;
    top: 1px;
    right: 1px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--gg-warning);
    border: 1px solid #fff;
}

.badge.shift-D { background-color: #198754 !important; color: #fff; }
.badge.shift-N { background-color: #0d6efd !important; color: #fff; }
.badge.shift-L { background-color: #dc3545 !important; color: #fff; }

/* Sticky primera columna en matrix para scroll horizontal móvil */
@media (max-width: 991.98px) {
    .matrix-table {
        font-size: 0.72rem;
        table-layout: auto;
        width: auto;
        min-width: 100%;
    }

    .matrix-table .col-info {
        font-size: 0.68rem;
    }

    .matrix-table .col-dia {
        font-size: 0.62rem;
        min-width: 40px;
    }

    .turno-cell {
        font-size: 0.72rem;
        min-width: 40px;
    }

    .dia-header-nombre {
        font-size: 0.58rem;
    }

    .dia-header-fecha {
        font-size: 0.52rem;
    }

    .matrix-table thead th:nth-child(-n+2),
    .matrix-table tbody td:nth-child(-n+2) {
        position: sticky;
        z-index: 2;
        background-color: inherit;
    }

    .matrix-table thead th:nth-child(1),
    .matrix-table tbody td:nth-child(1) {
        left: 0;
        min-width: 28px;
    }

    .matrix-table thead th:nth-child(2),
    .matrix-table tbody td:nth-child(2) {
        left: 28px;
        min-width: 100px;
        max-width: 120px;
    }

    .matrix-table thead tr.table-dark th:nth-child(-n+2) {
        background-color: #212529;
    }

    .matrix-table thead tr.table-light th:nth-child(-n+2) {
        background-color: #f8f9fa;
    }

    .matrix-table tbody tr.table-secondary td:nth-child(-n+2) {
        background-color: #e2e3e5;
    }

    .matrix-table tbody tr td:nth-child(-n+2) {
        background-color: #fff;
    }
}

/* Vista mes: cuando hay muchos días, compactar más */
@media (min-width: 992px) {
    .matrix-table.vista-mes .col-dia {
        font-size: 0.62rem;
        padding: 0.15rem 0 !important;
    }

    .matrix-table.vista-mes .turno-cell {
        font-size: 0.72rem;
        padding: 0.15rem 0 !important;
    }

    .matrix-table.vista-mes .col-info {
        font-size: 0.68rem;
    }

    .matrix-table.vista-mes .dia-header-nombre {
        font-size: 0.58rem;
    }

    .matrix-table.vista-mes .dia-header-fecha {
        font-size: 0.55rem;
    }
}

/* Vista semana: encabezados de día más grandes y claros */
@media (min-width: 992px) {
    .matrix-table:not(.vista-mes) .dia-header-nombre {
        font-size: 0.78rem;
    }

    .matrix-table:not(.vista-mes) .dia-header-fecha {
        font-size: 0.7rem;
    }

    .matrix-table:not(.vista-mes) .turno-cell {
        font-size: 0.9rem;
        padding: 0.3rem 0 !important;
    }
}

/* ─── Tarjetas de turno para móvil (panel guardia) ─────────── */
.turno-card-mobile {
    border-radius: 0.75rem;
    border: none;
    overflow: hidden;
    transition: transform 0.15s;
}

.turno-card-mobile:active {
    transform: scale(0.98);
}

.turno-dia-header {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.35rem 0;
    text-align: center;
}

.turno-dia-body {
    padding: 0.5rem;
    text-align: center;
    min-height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
}

.turno-dia-body.shift-D { background-color: #198754; color: #fff; }
.turno-dia-body.shift-N { background-color: #0d6efd; color: #fff; }
.turno-dia-body.shift-L { background-color: #dc3545; color: #fff; }
.turno-dia-body.shift-empty { background-color: #e9ecef; color: #adb5bd; }

.turno-hoy {
    box-shadow: 0 0 0 3px var(--gg-warning), 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* ─── Badges ───────────────────────────────────────────────── */
.badge {
    font-weight: 500;
    letter-spacing: 0.02em;
}

/* ─── Alerts ───────────────────────────────────────────────── */
.alert {
    border-radius: 0.5rem;
    border: none;
}

/* ─── Footer ───────────────────────────────────────────────── */
.footer-bar {
    font-size: 0.82rem;
}

/* ─── Mobile-specific utilities ────────────────────────────── */
@media (max-width: 575.98px) {
    h1.h3, .h3 {
        font-size: 1.2rem;
    }

    .card-body {
        padding: 0.875rem;
    }

    .fs-3 {
        font-size: 1.4rem !important;
    }

    .fs-4 {
        font-size: 1.2rem !important;
    }

    .btn-group .btn {
        font-size: 0.75rem;
        padding: 0.35rem 0.5rem;
    }
}

@media (max-width: 767.98px) {
    .main-content {
        padding: 0.75rem !important;
    }

    .d-flex.flex-wrap.gap-3.mb-4 {
        gap: 0.75rem !important;
    }
}

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

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

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

::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

/* ─── Bottom nav para móvil (panel guardia) ────────────────── */
.mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #fff;
    border-top: 1px solid #dee2e6;
    z-index: 1030;
    padding: 0.25rem 0;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.08);
}

.mobile-bottom-nav .nav-link {
    color: #6c757d;
    font-size: 0.65rem;
    padding: 0.35rem 0.5rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
    transition: color 0.15s;
    min-width: 60px;
}

.mobile-bottom-nav .nav-link i {
    font-size: 1.1rem;
}

.mobile-bottom-nav .nav-link.active,
.mobile-bottom-nav .nav-link:hover {
    color: var(--gg-accent);
}

@media (min-width: 992px) {
    .mobile-bottom-nav {
        display: none !important;
    }
}

@media (max-width: 991.98px) {
    body.has-bottom-nav {
        padding-bottom: 65px;
    }

    body.has-bottom-nav .footer-bar {
        margin-bottom: 60px;
    }
}

/* ─── Print ────────────────────────────────────────────────── */
@media print {
    .navbar,
    .sidebar-offcanvas,
    .footer-bar,
    .mobile-bottom-nav,
    .btn:not(.no-print-hide) {
        display: none !important;
    }

    .main-content {
        margin: 0 !important;
        padding: 0 !important;
    }

    .card {
        box-shadow: none !important;
        border: 1px solid #ddd !important;
    }

    .shift-D, .shift-N, .shift-L,
    .turno-dia-body.shift-D, .turno-dia-body.shift-N, .turno-dia-body.shift-L {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .matrix-table {
        font-size: 8px !important;
    }

    .matrix-table th,
    .matrix-table td {
        padding: 2px 3px !important;
    }
}
