* {
    --primary-color: #0056b3;
    --secondary-color: #6c757d;
    --success-color: #28a745;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --light-bg: #f8f9fa;
    --white: #ffffff;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.12);
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes slideOut {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

body {
    background-color: #f5f7fa;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: #2c3e50;
    line-height: 1.6;
}

body.not-authenticated {
    background: linear-gradient(135deg, #1a365d 0%, #0d1f3c 50%, #0a1628 100%);
}

body.not-authenticated .navbar,
body.not-authenticated #mainLayout {
    display: none !important;
}

.navbar {
    background: linear-gradient(135deg, #0056b3 0%, #003d82 100%);
    box-shadow: var(--shadow-md);
    padding: 1rem;
}

.navbar-brand {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: #ffffff !important;
}

#mainLayout {
    display: flex;
    height: calc(100vh - 70px);
}

#sidebar {
    width: 200px;
    min-width: 200px;
    background-color: #fff;
    border-right: 1px solid #e9ecef;
    overflow-y: auto;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
}

#mainContent {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
}

.nav-link-custom {
    color: #495057;
    padding: 0.65rem 1rem;
    border-left: 3px solid transparent;
    transition: all 0.3s ease;
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
}

.nav-link-custom:hover {
    background-color: #f8f9fa;
    color: var(--primary-color);
    border-left-color: var(--primary-color);
}

.nav-link-custom.active {
    background-color: #e7f0f9;
    color: var(--primary-color);
    border-left-color: var(--primary-color);
}

.section-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: #2c3e50;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #e9ecef;
}

.card {
    box-shadow: var(--shadow-md);
    border: none;
    border-radius: 10px;
    transition: all 0.3s ease;
    overflow: hidden;
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

.card-header {
    background: linear-gradient(135deg, #0056b3 0%, #003d82 100%);
    color: white;
    font-weight: 600;
    border: none;
}

.status-badge {
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    display: inline-block;
}

.status-completed {
    background-color: #d4edda;
    color: #155724;
}

.status-in-progress {
    background-color: #fff3cd;
    color: #856404;
}

.status-not-started {
    background-color: #e2e3e5;
    color: #383d41;
}

.progress-container {
    background-color: #e9ecef;
    border-radius: 8px;
    overflow: hidden;
}

.progress-bar-custom {
    height: 28px;
    font-size: 0.9rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cohort-card {
    border-left: 5px solid #007bff;
    transition: all 0.3s ease;
}

.cohort-card:hover {
    border-left-color: #0056b3;
}

.cohort-card.low-progress {
    border-left-color: #dc3545;
}

.cohort-card.medium-progress {
    border-left-color: #ffc107;
}

.cohort-card.high-progress {
    border-left-color: #28a745;
}

.unit-row {
    border-bottom: 1px solid #e9ecef;
    padding: 1rem 0;
}

.unit-row:last-child {
    border-bottom: none;
}

.badge-issue-open {
    background-color: #f8d7da;
    color: #721c24;
}

.badge-issue-progress {
    background-color: #fff3cd;
    color: #856404;
}

.badge-issue-resolved {
    background-color: #d4edda;
    color: #155724;
}

.table-hover tbody tr:hover {
    background-color: #f8f9fa;
    cursor: pointer;
}

.table {
    font-size: 0.95rem;
}

.table thead {
    background-color: #f8f9fa;
    font-weight: 600;
}

.metric-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 10px;
    padding: 1.5rem;
    margin-bottom: 1rem;
}

.kpi-card {
    border-radius: 10px;
    padding: 1.5rem;
    background-color: white;
    border-left: 4px solid #0056b3;
    box-shadow: var(--shadow-sm);
    border-top: none;
    border-right: none;
    border-bottom: none;
    transition: all 0.3s ease;
}

.kpi-card:hover {
    box-shadow: var(--shadow-md);
}

.kpi-card.bg-programs {
    border-left-color: #0056b3;
}

.kpi-card.bg-cohorts {
    border-left-color: #6c757d;
}

.kpi-card.bg-progress {
    border-left-color: #28a745;
}

.kpi-card.bg-attendance {
    border-left-color: #17a2b8;
}

.kpi-card.bg-issues {
    border-left-color: #dc3545;
}

.kpi-value {
    font-size: 2.2rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 0.5rem;
    color: #2c3e50;
}

.kpi-label {
    font-size: 0.9rem;
    color: #495057;
    font-weight: 500;
}

.kpi-subtitle {
    font-size: 0.8rem;
    color: #6c757d;
    margin-top: 0.5rem;
}

.metric-value {
    font-size: 2.5rem;
    font-weight: bold;
}

.metric-label {
    font-size: 1rem;
    opacity: 0.9;
}

.btn-sm-icon {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

.btn-primary {
    background: linear-gradient(135deg, #0056b3 0%, #003d82 100%);
    border: none;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #003d82 0%, #002650 100%);
    transform: translateY(-2px);
}

#loginModal .modal-header {
    background: linear-gradient(135deg, #0056b3 0%, #003d82 100%);
    color: white;
}

#loginModal .modal-body {
    padding: 2rem;
}

#loginModal .form-control {
    border-radius: 8px;
    border: 1px solid #dee2e6;
    padding: 0.75rem;
    font-size: 1rem;
}

#loginModal .form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(0, 86, 179, 0.25);
}

#loginForm button {
    border-radius: 8px;
    font-weight: 600;
    padding: 0.75rem;
}

/* 5-Column Layout for KPI Cards */
.col-lg-2-4 {
    flex: 0 0 calc(20% - 0.75rem);
    max-width: calc(20% - 0.75rem);
}

@media (max-width: 1400px) {
    .col-lg-2-4 {
        flex: 0 0 calc(33.333% - 0.75rem);
        max-width: calc(33.333% - 0.75rem);
    }
}

@media (max-width: 991px) {
    .col-lg-2-4 {
        flex: 0 0 calc(50% - 0.75rem);
        max-width: calc(50% - 0.75rem);
    }
}

/* Mobile Responsive Design */
@media (max-width: 991px) {
    .navbar {
        padding: 0.75rem 0.5rem;
    }

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

    .btn-light {
        padding: 0.4rem 0.6rem !important;
        font-size: 0.8rem !important;
    }

    .btn-light .me-1 {
        margin-right: 0.25rem !important;
    }

    #mainLayout {
        flex-direction: column;
        height: auto;
    }

    #sidebar {
        width: 100%;
        max-height: 0;
        overflow: hidden;
        border-right: none;
        border-bottom: 1px solid #e9ecef;
        transition: max-height 0.3s ease;
    }

    #sidebar.mobile-open {
        max-height: 500px;
        overflow-y: auto;
    }

    #mainContent {
        padding: 1rem;
        min-height: calc(100vh - 200px);
    }

    .nav-link-custom {
        padding: 0.75rem 1rem;
    }

    .section-title {
        font-size: 1.4rem;
        margin-bottom: 1rem;
        padding-bottom: 0.75rem;
    }

    .table {
        font-size: 0.85rem;
    }

    .table th, .table td {
        padding: 0.5rem !important;
    }

    .card {
        margin-bottom: 0.75rem;
    }

    .modal-dialog {
        margin: 0.5rem;
    }
}

@media (max-width: 768px) {
    html, body {
        font-size: 14px;
    }

    .navbar {
        padding: 0.5rem;
    }

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

    .d-flex.gap-2 {
        gap: 0.35rem !important;
    }

    .btn {
        padding: 0.4rem 0.5rem !important;
        font-size: 0.75rem !important;
    }

    .btn-light {
        padding: 0.35rem 0.45rem !important;
    }

    #sidebar {
        position: fixed;
        left: 0;
        top: 70px;
        right: 0;
        z-index: 1000;
        max-height: 0;
        box-shadow: var(--shadow-md);
    }

    #mainContent {
        padding: 1rem 0.75rem;
    }

    .section-title {
        font-size: 1.2rem;
        margin-bottom: 0.75rem;
    }

    .card-body {
        padding: 0.75rem;
    }

    .form-control, .form-select {
        padding: 0.4rem 0.5rem;
        font-size: 0.9rem;
    }

    h3 {
        font-size: 1.1rem;
    }

    h5 {
        font-size: 0.95rem;
    }

    .table {
        font-size: 0.75rem;
    }

    .table th, .table td {
        padding: 0.35rem !important;
    }

    .row > [class*="col-"] {
        padding-left: 0.35rem;
        padding-right: 0.35rem;
    }

    .mb-3 {
        margin-bottom: 0.75rem !important;
    }

    .mb-2 {
        margin-bottom: 0.5rem !important;
    }

    .text-end {
        text-align: left !important;
    }

    .metric-card {
        padding: 1rem;
    }

    .metric-value {
        font-size: 1.75rem;
    }

    .progress {
        height: 18px !important;
    }

    .alert {
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
    }

    #userInfo {
        display: none !important;
    }

    #loginSection {
        display: block !important;
    }

    .navbar-brand .me-2 {
        margin-right: 0.25rem !important;
    }
}

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

    .btn {
        padding: 0.35rem 0.4rem !important;
        font-size: 0.65rem !important;
    }

    .btn-light {
        padding: 0.3rem 0.35rem !important;
    }

    #mainContent {
        padding: 0.75rem 0.5rem;
    }

    .section-title {
        font-size: 1rem;
        margin-bottom: 0.5rem;
    }

    .card {
        margin-bottom: 0.5rem;
    }

    .card-body {
        padding: 0.5rem;
    }

    .form-control, .form-select {
        padding: 0.35rem 0.4rem;
        font-size: 0.85rem;
    }

    h3 {
        font-size: 1rem;
    }

    h5 {
        font-size: 0.9rem;
    }

    .table {
        font-size: 0.7rem;
    }

    .table th, .table td {
        padding: 0.25rem !important;
    }

    .badge {
        padding: 0.3rem 0.5rem !important;
        font-size: 0.65rem !important;
    }

    .status-badge {
        padding: 0.25rem 0.5rem;
        font-size: 0.7rem;
    }

    .modal-body {
        padding: 1rem 0.75rem;
    }

    .metric-value {
        font-size: 1.4rem;
    }

    .cohort-card {
        border-left-width: 3px;
    }
}

/* Hamburger Menu for Mobile */
#mobileToggle {
    display: none;
}

@media (max-width: 991px) {
    #mobileToggle {
        display: block !important;
        border: none;
        background: none;
        color: white;
        font-size: 1.25rem;
        cursor: pointer;
        padding: 0.5rem;
    }

    #mobileToggle:hover {
        opacity: 0.8;
    }
}

/* Ensure proper scrolling on mobile */
@media (max-width: 768px) {
    body, html {
        overflow-x: hidden;
    }

    #mainLayout {
        overflow-x: hidden;
    }

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

/* Trainer Dashboard Compact Styles */
#trainer .card {
    transform: none;
}

#trainer .card:hover {
    transform: none;
    box-shadow: var(--shadow-sm);
}

#trainer .card-header {
    font-size: 0.9rem;
    padding: 0.5rem 0.75rem;
}

#trainer .form-select-sm {
    font-size: 0.875rem;
}

#trainer .table th,
#trainer .table td {
    padding: 0.35rem 0.5rem;
    font-size: 0.85rem;
    vertical-align: middle;
}

#trainer .table input[type="number"],
#trainer .table select,
#trainer .table input[type="text"] {
    font-size: 0.8rem;
    padding: 0.2rem 0.4rem;
}

#trainer .btn-sm {
    font-size: 0.8rem;
}

#trainerPlaceholder {
    background: transparent;
}

#trainerPlaceholder .bg-light {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%) !important;
}

/* Sticky table headers */
#trainer thead.sticky-top th {
    background: #f8f9fa;
    position: sticky;
    top: 0;
    z-index: 10;
}

/* Spreadsheet-style attendance grid */
.attendance-spreadsheet {
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.875rem;
}

.attendance-spreadsheet .sticky-col {
    position: sticky;
    left: 0;
    z-index: 10;
    background: #ffffff !important;
    border-right: 2px solid #3b5998;
    box-shadow: 4px 0 12px -2px rgba(59, 89, 152, 0.2);
    min-width: 160px;
    padding: 10px 12px !important;
}

.attendance-spreadsheet thead .sticky-col {
    z-index: 15;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%) !important;
    font-weight: 600;
    color: #495057;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
}

.attendance-spreadsheet tfoot .sticky-col {
    z-index: 12;
    background: #f1f3f5 !important;
}

.attendance-spreadsheet tbody tr {
    transition: background-color 0.15s ease;
}

.attendance-spreadsheet tbody tr:hover {
    background-color: rgba(59, 89, 152, 0.04) !important;
}

.attendance-spreadsheet tbody tr:nth-child(even) {
    background-color: #fafbfc;
}

.attendance-spreadsheet tbody tr:nth-child(even):hover {
    background-color: rgba(59, 89, 152, 0.06) !important;
}

.attendance-spreadsheet .date-col {
    min-width: 58px;
    padding: 6px 4px !important;
    text-align: center;
    background: linear-gradient(180deg, #f8f9fa 0%, #ffffff 100%);
    border-bottom: 2px solid #e9ecef;
}

.attendance-spreadsheet .date-col .date-label {
    font-weight: 600;
    color: #495057;
    font-size: 0.8rem;
}

.attendance-spreadsheet .date-col .delete-date-btn {
    opacity: 0;
    transition: opacity 0.2s ease;
}

.attendance-spreadsheet .date-col:hover .delete-date-btn {
    opacity: 1;
}

.attendance-spreadsheet .add-date-col {
    background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%) !important;
    border-left: 2px dashed #4caf50;
}

.attendance-spreadsheet tfoot td {
    border-top: 2px solid #dee2e6;
    background: #f8f9fa;
}

.attendance-spreadsheet .attendance-cell {
    transition: all 0.15s ease;
    border-radius: 6px !important;
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.attendance-spreadsheet .attendance-cell:hover {
    transform: scale(1.15);
    box-shadow: 0 3px 8px rgba(0,0,0,0.2);
}

.attendance-spreadsheet .attendance-cell:focus {
    outline: 3px solid rgba(59, 89, 152, 0.5);
    outline-offset: 2px;
}

.attendance-spreadsheet .attendance-cell.bg-light {
    background: #e9ecef !important;
    color: #adb5bd !important;
    border: 1px dashed #ced4da;
}

.attendance-spreadsheet .attendance-cell.bg-success {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%) !important;
}

.attendance-spreadsheet .attendance-cell.bg-danger {
    background: linear-gradient(135deg, #dc3545 0%, #e83e8c 100%) !important;
}

.attendance-spreadsheet .attendance-cell.bg-warning {
    background: linear-gradient(135deg, #ffc107 0%, #fd7e14 100%) !important;
}

.attendance-spreadsheet .attendance-cell.bg-secondary {
    background: linear-gradient(135deg, #6c757d 0%, #495057 100%) !important;
}

.attendance-spreadsheet .attendance-cell.bg-info {
    background: linear-gradient(135deg, #17a2b8 0%, #6610f2 100%) !important;
}

.attendance-spreadsheet .student-name {
    font-weight: 500;
    color: #212529;
    display: flex;
    align-items: center;
    gap: 8px;
}

.attendance-spreadsheet .student-name::before {
    content: '';
    width: 8px;
    height: 8px;
    background: #3b5998;
    border-radius: 50%;
    flex-shrink: 0;
}

.attendance-spreadsheet .avg-cell {
    font-weight: 700;
    font-size: 0.85rem;
}

.attendance-spreadsheet .avg-cell.text-success {
    color: #28a745 !important;
}

.attendance-spreadsheet .avg-cell.text-warning {
    color: #e67700 !important;
}

.attendance-spreadsheet .avg-cell.text-danger {
    color: #dc3545 !important;
}

#inlineDateInput {
    border: 1px dashed #28a745;
    background: #fff;
}

#inlineDateInput:focus {
    border-color: #28a745;
    box-shadow: 0 0 0 2px rgba(40, 167, 69, 0.2);
}

#inlineStudentName {
    border: 1px dashed #0056b3;
}

#inlineStudentName:focus {
    border-color: #0056b3;
    box-shadow: 0 0 0 2px rgba(0, 86, 179, 0.2);
}

.login-modal-content {
    border: none;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.login-modal-header {
    background: linear-gradient(135deg, #0056b3 0%, #003d82 100%);
    color: white;
    padding: 2rem 1.5rem;
}

.login-icon-wrapper {
    width: 80px;
    height: 80px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    backdrop-filter: blur(10px);
}

.login-modal-content .modal-body {
    background: #fff;
}

.login-modal-content .input-group-text {
    border-radius: 8px 0 0 8px;
}

.login-modal-content .form-control {
    border-radius: 0 8px 8px 0;
    padding: 0.75rem 1rem;
}

.login-modal-content .btn-primary {
    border-radius: 8px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.modal-backdrop.show {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    opacity: 0.95;
}

#loginModal .modal-dialog {
    max-width: 400px;
}
