/* 60-30-10 Color Rule Implementation */
/* 60% - #F1F2EE (Light background) */
/* 30% - #0F2A47 (Dark blue for navigation and headers) */
/* 10% - #C6EF43 (Bright green for accents and CTAs) */

/* CSS Variables for consistency */
:root {
    --primary-color: #F1F2EE;
    /* 60% */
    --secondary-color: #0F2A47;
    /* 30% */
    --accent-color: #C6EF43;
    /* 10% */
}

/* iOS Safe Area Support - Dynamic Island & Notch */
@supports (padding-top: env(safe-area-inset-top)) {

    /* Solo aplicar padding a los lados y abajo, no arriba para el body */
    body {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
        padding-bottom: env(safe-area-inset-bottom);
    }

    /* Headers específicos que necesitan evitar la Dynamic Island */
    .header-ac {
        padding-top: calc(1rem + env(safe-area-inset-top)) !important;
        margin-top: 0 !important;
    }

    /* Para cualquier elemento que tenga position fixed en top */
    .navbar,
    nav,
    .fixed-top {
        padding-top: calc(0.5rem + env(safe-area-inset-top)) !important;
    }

    /* Contenedores principales que necesitan espacio extra */
    .container-fluid:first-child,
    .container:first-child {
        margin-top: env(safe-area-inset-top);
    }
}

/* Específico para iPhone con Dynamic Island (fallback más agresivo) */
@media only screen and (device-width: 393px) and (device-height: 852px) and (-webkit-device-pixel-ratio: 3) {
    .header-ac {
        padding-top: 3rem !important;
    }
}

@media only screen and (device-width: 428px) and (device-height: 926px) and (-webkit-device-pixel-ratio: 3) {
    .header-ac {
        padding-top: 3rem !important;
    }
}

/* iPhone 15 Pro Max */
@media only screen and (device-width: 430px) and (device-height: 932px) and (-webkit-device-pixel-ratio: 3) {
    .header-ac {
        padding-top: 3rem !important;
    }
}

/* Global Styles */
body {
    background-color: var(--primary-color);
    color: var(--secondary-color);
    font-family: 'Public Sans', sans-serif;
    margin: 0;
    padding: 0;
}

/* Solución universal para Dynamic Island */
@media (display-mode: standalone) {
    .header-ac {
        padding-top: 3.5rem !important;
        /* Mantener el background original azul */
        background-color: var(--secondary-color);
        color: var(--primary-color);
        position: relative;
        z-index: 999;
    }

    /* Asegurar que el contenido no se superponga */
    .container-fluid:first-child {
        margin-top: 0;
    }
}

/* JavaScript Enhanced Dynamic Island Support for iOS 26 & iPhone 16 */
body.has-dynamic-island .header-ac {
    position: sticky !important;
    top: 0 !important;
    z-index: 1050 !important;
    /* Mantener el background original azul */
    background-color: var(--secondary-color) !important;
    color: var(--primary-color) !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05) !important;
}

body.has-dynamic-island .header-ac .container-fluid {
    position: relative !important;
}

/* Ensure content doesn't hide behind Dynamic Island adjusted header */
body.has-dynamic-island main {
    margin-top: 0 !important;
    padding-top: 0 !important;
}


/* Sidebar Navigation Styles */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 250px;
    background-color: var(--secondary-color);
    color: var(--primary-color);
    transform: translateX(0);
    transition: transform 0.3s ease, width 0.3s ease;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 10px rgba(15, 42, 71, 0.1);
}

.navbar-brand {
    font-weight: bold;
    color: #F1F2EE !important;
    /* 60% - Light text on dark background */
}

.navbar-dark {
    background-color: var(--secondary-color) !important;
    /* 30% - Navigation background */
}

.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    background: linear-gradient(135deg, var(--secondary-color) 0%, #F1F2EE 100%);
    /* 30% to 60% gradient */
}

.login-card {
    background: #F1F2EE;
    /* 60% - Card background */
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(15, 42, 71, 0.2);
    /* 30% shadow */
}

.btn-primary {
    background-color: var(--accent-color);
    /* 10% - Primary button */
    border: 2px solid var(--accent-color);
    color: var(--secondary-color);
    /* 30% - Button text */
    font-weight: 600;
}

.btn-primary:hover {
    background-color: #B8E03A;
    /* Slightly darker green */
    border-color: #B8E03A;
    color: var(--secondary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(198, 239, 67, 0.3);
}

.btn-secondary {
    background-color: var(--secondary-color);
    /* 30% - Secondary button */
    border: 2px solid var(--secondary-color);
    color: #F1F2EE;
    /* 60% - Button text */
}

.btn-secondary:hover {
    background-color: #1A3A5F;
    border-color: #1A3A5F;
    color: #F1F2EE;
}

.alert {
    border-radius: 10px;
    border: none;
}

.alert-success {
    background-color: var(--accent-color);
    /* 10% - Success alerts */
    color: var(--secondary-color);
    /* 30% - Alert text */
    border-left: 4px solid var(--secondary-color);
}

.alert-danger {
    background-color: #FFE5E5;
    color: var(--secondary-color);
    border-left: 4px solid #FF4444;
}

.form-control {
    background-color: #F1F2EE;
    /* 60% - Input background */
    border: 1px solid var(--secondary-color);
    /* 30% - Input border */
    color: var(--secondary-color);
}

.form-control:focus {
    background-color: #F1F2EE;
    border-color: var(--accent-color);
    /* 10% - Focus border */
    box-shadow: 0 0 0 0.2rem rgba(198, 239, 67, 0.25);
    color: var(--secondary-color);
}

.form-label {
    color: var(--secondary-color);
    /* 30% - Label text */
    font-weight: 600;
}

.dropdown-menu {
    background-color: #F1F2EE;
    /* 60% - Dropdown background */
    border: 2px solid var(--secondary-color);
    /* 30% - Dropdown border */
}

.dropdown-item {
    color: var(--secondary-color);
    /* 30% - Dropdown text */
}

.dropdown-item:hover {
    background-color: var(--accent-color);
    /* 10% - Dropdown hover */
    color: var(--secondary-color);
}

.loading {
    display: none;
}

.spinner-border-sm {
    width: 1rem;
    height: 1rem;
}

/* Card styling */
.card {
    background-color: #F1F2EE;
    border-radius: 12px;
}

.card-header {
    background-color: var(--secondary-color);
    /* 30% - Card header */
    color: #F1F2EE;
    /* 60% - Header text */
    border-bottom: 2px solid var(--accent-color);
    /* 10% - Header accent */
}

.h5-card-h {
    display: grid;
    grid-template-columns: 1fr 20px;
    gap: 5px;
}

/* Table styling */
.table {
    background-color: #F1F2EE;
    /* 60% - Table background */
    color: var(--secondary-color);
    /* 30% - Table text */
}

.table-bordered {
    border-color: var(--secondary-color);
    /* 30% - Table borders */
}

.table-bordered td,
.table-bordered th {
    border-color: var(--secondary-color);
}

/* Links */
a {
    color: var(--secondary-color);
    /* 30% - Link color */
}

a:hover {
    color: var(--accent-color);
    /* 10% - Link hover */
}

.sidebar-header {
    padding: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--primary-color);
}

.sidebar-logo {
    border-radius: 8px;
    filter: drop-shadow(2px 0px 4px rgba(198, 239, 67, 0.3));
}

.brand-text {
    color: var(--primary-color);
    font-weight: 700;
}

.sidebar-toggle {
    background: transparent;
    border: none;
    color: var(--accent-color);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.sidebar-toggle:hover {
    background-color: var(--accent-color);
    color: var(var(--secondary-color));
}

.sidebar-menu {
    flex: 1;
    padding: 1rem 0;
}

.sidebar-menu .nav {
    list-style: none;
    margin: 0;
    padding: 0;
}

.sidebar-menu .nav-item {
    margin: 0.25rem 0;
}

.sidebar-menu .nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0.875rem 1.5rem;
    color: var(--primary-color);
    text-decoration: none;
    transition: all 0.3s ease;
    border-radius: 0;
    font-weight: 500;
}

.sidebar-menu .nav-link:hover {
    background-color: var(--accent-color);
    color: var(--secondary-color);
    transform: translateX(5px);
}

.sidebar-menu .nav-link.active {
    background-color: var(--accent-color);
    color: var(--secondary-color);
    border-left: 4px solid var(--secondary-color);
    font-weight: 700;
}

.sidebar-menu .nav-link i {
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
}

.sidebar-session {
    padding: 1rem 1.5rem;
    border-top: 2px solid var(--accent-color);
    margin-top: auto;
}

.sidebar-session .dropdown-toggle {
    color: var(--primary-color);
    padding: 0.75rem 0;
    border-radius: 8px;
    transition: all 0.2s ease;
    width: 100%;
}

.sidebar-session .dropdown-toggle:hover {
    background-color: rgba(198, 239, 67, 0.1);
    color: var(--accent-color);
}

.sidebar-session .dropdown-menu {
    background-color: var(--primary-color);
    border: 2px solid var(--secondary-color);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(15, 42, 71, 0.2);
    margin-top: 0.5rem;
}

.sidebar-session .dropdown-item {
    color: var(--secondary-color);
    padding: 0.75rem 1rem;
    transition: all 0.2s ease;
}

.sidebar-session .dropdown-item:hover {
    background-color: var(--accent-color);
    color: var(--secondary-color);
}

/* Main Content with Sidebar */
body:has(.sidebar) main {
    margin-left: 250px;
    transition: margin-left 0.3s ease;
    min-height: 100vh;
}

/* Mobile Responsive */
@media (max-width: 767.98px) {
    .sidebar {
        transform: translateX(-100%);
        width: 280px;
    }

    .sidebar.show {
        transform: translateX(0);
    }

    body:has(.sidebar) main {
        margin-left: 0;
    }

    /* Overlay for mobile */
    .sidebar.show::before {
        content: '';
        position: fixed;
        top: 0;
        left: 280px;
        right: 0;
        bottom: 0;
        background-color: rgba(15, 42, 71, 0.5);
        z-index: -1;
    }
}

/* Auth Pages */
body .auth-main {
    background: linear-gradient(-45deg, --secondary-color 0%, #F1F2EE 100%);
    /* 30% to 60% gradient */
}

.auth-main {
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-card {
    background: #F1F2EE;
    /* 60% - Card background */
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(15, 42, 71, 0.1);
    /* 30% shadow */
    padding: 2rem;
    width: 100%;
    max-width: 400px;
    text-align: center;
    border: 2px solid var(--accent-color);
    /* 10% - Accent border */
}

/* Dashboard Layout */
#body {
    background-color: #F1F2EE;
    /* 60% - Main background */
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    height: fit-content;
    display: grid;
    grid-template-columns: auto auto;
    grid-template-rows: 60px 1fr;
    grid-template-areas:
        "nav header header"
        "nav content content"
        "nav content content";
    color: var(--secondary-color);
    /* 30% - Main text color */
}

/* Navigation */
.navigation {
    grid-area: nav;
    background-color: var(--secondary-color);
    /* 30% - Navigation background */
    color: #F1F2EE;
    /* 60% - Navigation text */
    display: grid;
    padding: 20px;
    transition: width 0.3s;
}

#verticalNav {
    width: 240px;
    background: var(--secondary-color);
    /* 30% - Navigation background */
    color: #F1F2EE;
    /* 60% - Navigation text */
    display: flex;
    flex-direction: column;
    transition: width 0.2s ease;
}

#verticalNav .brand {
    padding: 16px;
    font-weight: 600;
    color: #F1F2EE;
    /* 60% - Brand text */
    font-size: 18px;
    text-align: center;
    padding-bottom: 15px;
}

#verticalNav .links {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 8px;
}

#verticalNav .nav-link {
    color: #F1F2EE;
    /* 60% - Link text */
    padding: 10px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    border-radius: 6px;
    transition: all 0.3s ease;
}

#verticalNav .nav-link:hover {
    background-color: var(--accent-color);
    /* 10% - Link hover background */
    color: var(--secondary-color);
    /* 30% - Link hover text */
    transform: translateX(5px);
}

#verticalNav .nav-link i {
    font-size: 18px;
    color: var(--accent-color);
    /* 10% - Icon color */
}

/* Collapsed Navigation */
#verticalNav.vertical-collapsed {
    width: 30px !important;
}

#verticalNav.vertical-collapsed .nav-link {
    justify-content: center;
    padding: 8px 0;
}

#verticalNav.vertical-collapsed .link-text {
    display: none;
}

#verticalNav.vertical-collapsed .brand {
    display: none;
}

/* Navigation Button */
#expandCollapse {
    background-color: var(--accent-color);
    /* 10% - Button background */
    color: var(--secondary-color);
    /* 30% - Button text */
    border: 2px solid var(--accent-color);
    border-radius: 6px;
    transition: all 0.3s ease;
}

#expandCollapse:hover {
    background-color: #B8E03A;
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(198, 239, 67, 0.3);
}

/* Header */
.header {
    grid-area: header;
    background-color: var(--secondary-color);
    /* 30% - Header background */
    color: #F1F2EE;
    /* 60% - Header text */
    padding: 1rem;
    border-bottom: 3px solid var(--accent-color);
    /* 10% - Header accent */
}

.top-header {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 30px;
    padding: 15px 20px 0 20px;
}

/* Content Area */
.content-area {
    grid-area: content;
    padding: 20px;
    background-color: #F1F2EE;
    /* 60% - Content background */
    /* 30% - Content border */
    color: var(--secondary-color);
    /* 30% - Content text */
}


.table-bordered {
    border-color: var(--secondary-color);
    /* 30% - Table borders */
}

.table-bordered td,
.table-bordered th {
    border-color: var(--secondary-color);
    /* 30% - Cell borders */
}

.table tbody tr:hover {
    background-color: rgba(198, 239, 67, 0.1);
    /* 10% - Row hover with transparency */
}

/* Buttons */
.btn-primary {
    background-color: var(--accent-color);
    /* 10% - Primary button */
    border-color: var(--accent-color);
    color: var(--secondary-color);
    /* 30% - Button text */
    font-weight: 600;
}

.btn-primary:hover {
    background-color: #B8E03A;
    border-color: #B8E03A;
    color: var(--secondary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(198, 239, 67, 0.3);
}

.btn-secondary {
    background-color: var(--secondary-color);
    /* 30% - Secondary button */
    border-color: var(--secondary-color);
    color: #F1F2EE;
    /* 60% - Button text */
}

.btn-secondary:hover {
    background-color: #1A3A5F;
    border-color: #1A3A5F;
    color: #F1F2EE;
}

.btn-danger {
    background-color: #FF4444;
    border-color: #FF4444;
    color: #F1F2EE;
    /* 60% - Button text */
}

.btn-danger:hover {
    background-color: #FF2222;
    border-color: #FF2222;
    color: #F1F2EE;
    transform: translateY(-2px);
}

/* Utility Classes */
.justify-content-right {
    justify-content: right !important;
}

.justify-content-center {
    justify-content: center !important;
}

/* Mobile Responsive */
@media (max-width: 767.98px) {
    #body {
        display: block;
        position: relative;
    }

    .navigation {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        z-index: 1000;
        background-color: rgba(15, 42, 71, 0.95);
        /* 30% with transparency */
        backdrop-filter: blur(5px);
    }

    .header {
        margin-left: 0;
        width: 100%;
    }

    .content-area {
        margin-left: 0;
        width: 100%;
    }

    /* Auto-collapse navbar on mobile */
    #verticalNav {
        width: 30px !important;
    }

    #verticalNav .brand {
        display: none;
    }

    #verticalNav .link-text {
        display: none;
    }

    #verticalNav .nav-link {
        justify-content: center;
        padding: 8px 0;
    }

    #collapseContainer {
        justify-content: center !important;
    }

    .cards-grid {
        display: grid;
        grid-template-columns: 1fr;
    }

    .table-desktop {
        display: none !important;
    }
}

@media (min-width: 768px) {
    .cards-grid {
        display: none !important;
    }

    .table-desktop {
        display: block !important;
    }

    /* Reset mobile overrides for desktop */
    .navigation {
        position: static;
        height: auto;
        z-index: auto;
        background-color: var(--secondary-color);
        /* 30% - Navigation background */
        backdrop-filter: none;
    }

    .header {
        margin-left: auto;
    }

    .content-area {
        margin-left: auto;
    }
}

/* Modal Styles */
.modal {
    background-color: rgba(15, 42, 71, 0.8);
    /* 30% overlay */
}

.modal-content {
    background-color: #F1F2EE;
    /* 60% - Modal background */
    border: 2px solid var(--secondary-color);
    /* 30% - Modal border */
    border-radius: 12px;
}

.modal-header {
    background-color: var(--secondary-color);
    /* 30% - Modal header */
    color: #F1F2EE;
    /* 60% - Header text */
    border-bottom: 2px solid var(--accent-color);
    /* 10% - Header accent */
}

.modal-footer {
    border-top: 1px solid var(--secondary-color);
    /* 30% - Footer border */
}

.form-control:focus {
    background-color: #F1F2EE;
    border-color: var(--accent-color);
    /* 10% - Focus border */
    box-shadow: 0 0 0 0.2rem rgba(198, 239, 67, 0.25);
    color: var(--secondary-color);
}

.form-label {
    color: var(--secondary-color);
    /* 30% - Label text */
    font-weight: 600;
}

/* Links */
a {
    color: var(--secondary-color);
    /* 30% - Link color */
    text-decoration: none;
}

a:hover {
    color: var(--accent-color);
    /* 10% - Link hover */
}

/* Alerts */
.alert-success {
    background-color: var(--accent-color);
    /* 10% - Success alerts */
    color: var(--secondary-color);
    /* 30% - Alert text */
    border-left: 4px solid var(--secondary-color);
    border: none;
}

.alert-danger {
    background-color: #FFE5E5;
    color: var(--secondary-color);
    border-left: 4px solid #FF4444;
    border: none;
}

.alert {
    border-radius: 10px;
}

.header-ac {
    padding: 15px;
    background-color: var(--secondary-color);
    color: var(--primary-color);
}

.attendance-cards {
    width: 100%;
    gap: 1rem;
}

.attendance-card {
    border: 1px solid rgba(15, 42, 71, 0.08);
    border-radius: 14px;
    background-color: #FFFFFF;
}

.attendance-card .card-body {
    padding: 1rem 1.25rem;
}

.attendance-card .badge {
    font-size: 0.75rem;
}

.attendance-card .text-muted {
    color: rgba(15, 42, 71, 0.65) !important;
}

@media (max-width: 767.98px) {
    #attendanceTableWrapper {
        display: none !important;
    }

    #attendanceCardsWrapper {
        display: grid;
        grid-template-columns: 1fr;
        gap: 1rem;
    }
}

@media (min-width: 768px) {
    #attendanceCardsWrapper {
        display: none !important;
    }
}

.header-button {
    color: var(--primary-color);
    font-weight: 500;
}

.header-button:hover {
    color: var(--accent-color);
    text-decoration: none;
}

.badge-margin {
    margin-left: 30px;
}

.info-icon {
    cursor: pointer;
    position: relative;
    display: inline-block;
}

.info-icon::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: -120%;
    left: -235%;
    transform: translateX(-50%);
    background-color: #44525b;
    font-size: 12px;
    color: #fff;
    padding: 4px 8px;
    border-radius: 4px;
    white-space: wrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s;
    min-width: 120px;
    max-width: 160px;
}

.info-icon:hover::after {
    opacity: 1;
    visibility: visible;
}