:root {
    --muhasaba-primary: #1a5276;
    --muhasaba-accent: #2e86c1;
    --muhasaba-success: #27ae60;
    --muhasaba-warning: #f39c12;
}

body {
    font-family: "Segoe UI", Tahoma, "Noto Sans Arabic", sans-serif;
    background-color: #f4f6f9;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.login-page {
    background: linear-gradient(135deg, var(--muhasaba-primary) 0%, var(--muhasaba-accent) 100%);
}

.navbar-dark.bg-primary {
    background-color: var(--muhasaba-primary) !important;
}

.stat-card {
    border: none;
    border-radius: 12px;
    transition: transform 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
}

.stat-card .stat-icon {
    font-size: 2.5rem;
    opacity: 0.8;
}

.kpi-bar {
    height: 8px;
    border-radius: 4px;
}

.rating-badge {
    font-size: 0.85rem;
    padding: 0.35em 0.65em;
}

.table th {
    font-weight: 600;
    color: var(--muhasaba-primary);
}

.card {
    border: none;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.card-header {
    background: white;
    border-bottom: 1px solid #eee;
    font-weight: 600;
}

.badge-excellent { background-color: #27ae60; }
.badge-good { background-color: #2e86c1; }
.badge-average { background-color: #f39c12; }
.badge-needs_improvement { background-color: #e74c3c; }

/* Follow-up surveys hub */
.followup-hub-header h2 {
    color: var(--muhasaba-primary);
    font-weight: 700;
}

.followup-mode-switch .btn {
    min-width: 7rem;
}

.followup-period-nav h5 {
    min-width: 9rem;
    text-align: center;
}

.followup-stat-card {
    border: none;
    border-radius: 12px;
    overflow: hidden;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.followup-stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
}

.followup-stat-card .stat-icon {
    font-size: 2rem;
    opacity: 0.45;
}

.followup-status-pills .nav-link {
    font-size: 0.85rem;
    color: #555;
    border-radius: 50rem;
    margin-left: 0.25rem;
}

.followup-status-pills .nav-link.active {
    background-color: var(--muhasaba-primary);
}

.followup-tabs .nav-link {
    font-weight: 600;
    color: #555;
    border: none;
    border-bottom: 3px solid transparent;
    border-radius: 0;
}

.followup-tabs .nav-link.active {
    color: var(--muhasaba-primary);
    border-bottom-color: var(--muhasaba-accent);
    background: transparent;
}

.followup-student-hero {
    background: linear-gradient(135deg, #1a5276 0%, #2e86c1 100%);
    color: white;
    border-radius: 12px;
}

.followup-student-hero .progress {
    background: rgba(255, 255, 255, 0.25);
}

.followup-guide-card {
    border-right: 4px solid;
    height: 100%;
}

.followup-action-btn-group .btn {
    white-space: nowrap;
}

/* Reports hub */
.reports-hub-header .followup-mode-switch .btn-primary {
    pointer-events: none;
}

.reports-table thead th {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: #666;
    border-bottom-width: 2px;
}

.reports-table tbody tr:hover {
    background-color: rgba(26, 82, 118, 0.04);
}

.reports-action-group .btn {
    padding: 0.25rem 0.5rem;
}

.reports-action-group .dropdown-menu {
    font-size: 0.875rem;
}

/* ===== Global responsive ===== */
html {
    overflow-x: clip;
}

img,
video,
canvas,
svg {
    max-width: 100%;
    height: auto;
}

/* Horizontal scroll for tables not wrapped in .table-responsive */
.card-body:has(table),
.card:has(> table),
form:has(table) {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.card-header.d-flex {
    flex-wrap: wrap;
    gap: 0.5rem;
}

.followup-tabs,
.followup-status-pills,
.nav-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.followup-tabs .nav-link,
.followup-status-pills .nav-link,
.nav-tabs .nav-link {
    white-space: nowrap;
}

.reports-action-group,
.followup-action-btn-group,
.btn-group-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.chart-container {
    position: relative;
    width: 100%;
    max-width: 100%;
}

@media (max-width: 991.98px) {
    main.container-fluid {
        padding-left: 0.875rem !important;
        padding-right: 0.875rem !important;
    }

    .navbar .nav-link .badge.bg-light {
        display: none;
    }

    .navbar-nav .nav-link {
        padding-top: 0.45rem;
        padding-bottom: 0.45rem;
    }

    .navbar-collapse.show {
        max-height: calc(100vh - 8rem);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
}

@media (max-width: 767.98px) {
    .d-flex.justify-content-between:not(.flex-nowrap) {
        flex-wrap: wrap;
        gap: 0.625rem;
    }

    h2,
    .h2 {
        font-size: 1.35rem;
    }

    h3,
    .h3 {
        font-size: 1.2rem;
    }

    .stat-card .stat-icon,
    .followup-stat-card .stat-icon {
        font-size: 1.65rem;
    }

    .followup-period-nav h5 {
        min-width: 0;
        font-size: 1rem;
    }

    .followup-period-nav form .form-control-sm,
    .followup-period-nav form .form-select-sm {
        width: 100% !important;
        min-width: 0 !important;
    }

    .followup-period-nav form {
        width: 100%;
    }

    .followup-period-nav form > div {
        flex: 1 1 auto;
        min-width: 5.5rem;
    }

    .table {
        font-size: 0.875rem;
    }

    .table .btn-sm {
        padding: 0.2rem 0.45rem;
        font-size: 0.78rem;
    }

    .card-body canvas {
        max-width: 100%;
    }

    .login-page .card-body.p-5 {
        padding: 1.75rem !important;
    }

    .card-body {
        padding: 1rem;
    }

    td.text-nowrap {
        white-space: normal !important;
    }
}

@media (max-width: 576px) {
    main.container-fluid {
        padding-left: 0.625rem !important;
        padding-right: 0.625rem !important;
        padding-top: 0.75rem !important;
    }

    .navbar-brand {
        font-size: 0.95rem;
        max-width: calc(100vw - 4.5rem);
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .followup-mode-switch,
    .reports-hub-header .followup-mode-switch {
        width: 100%;
    }

    .followup-mode-switch .btn {
        flex: 1;
        min-width: 0;
        padding-left: 0.35rem;
        padding-right: 0.35rem;
        font-size: 0.78rem;
    }

    .followup-hub-header h2 {
        font-size: 1.2rem;
    }

    .col-6 .fs-4 {
        font-size: 1.25rem !important;
    }

    .login-page .card-body.p-5 {
        padding: 1.25rem !important;
    }

    .login-page .card-body .bi-mortarboard-fill {
        font-size: 2.25rem !important;
    }

    .form-control-lg,
    .btn-lg {
        font-size: 1rem;
        padding-top: 0.5rem;
        padding-bottom: 0.5rem;
    }

    td.text-nowrap .btn,
    td.text-nowrap form {
        display: block;
        width: 100%;
        margin-bottom: 0.25rem;
    }

    td.text-nowrap .btn:last-child,
    td.text-nowrap form:last-child {
        margin-bottom: 0;
    }

    .login-page .container {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    body.has-mobile-nav {
        padding-bottom: calc(4.25rem + env(safe-area-inset-bottom, 0px));
    }

    body.has-mobile-nav .footer {
        padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
    }
}

/* Mobile bottom navigation */
@media (min-width: 992px) {
    .mobile-bottom-nav,
    #mobileNavMenu {
        display: none !important;
    }

    body.has-mobile-nav {
        padding-bottom: 0;
    }
}

.mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1030;
    display: flex;
    align-items: stretch;
    justify-content: space-around;
    background: #fff;
    border-top: 1px solid #dee2e6;
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.08);
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

.mobile-bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    min-height: 3.75rem;
    padding: 0.35rem 0.25rem;
    border: none;
    background: transparent;
    color: #666;
    font-size: 0.68rem;
    text-decoration: none;
    line-height: 1.2;
    transition: color 0.15s ease;
}

.mobile-bottom-nav-item i {
    font-size: 1.25rem;
}

.mobile-bottom-nav-item span {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 0 0.15rem;
}

.mobile-bottom-nav-item:hover,
.mobile-bottom-nav-item:focus {
    color: var(--muhasaba-primary);
}

.mobile-bottom-nav-item.active {
    color: var(--muhasaba-primary);
    font-weight: 600;
}

.mobile-bottom-nav-menu {
    cursor: pointer;
}

.mobile-nav-list .list-group-item {
    border-right: none;
    border-left: none;
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
}

.offcanvas-bottom {
    max-height: 70vh;
    border-top-left-radius: 1rem;
    border-top-right-radius: 1rem;
}

/* Form & modal responsive helpers */
@media (max-width: 575.98px) {
    .modal-dialog {
        margin: 0.5rem;
    }

    .input-group > .form-control,
    .input-group > .form-select {
        min-width: 0;
    }

    .row.g-3 > [class*="col-"] {
        min-width: 0;
    }
}
