/**
 * Student Data Migration Management System - Refined Modern UI/UX
 * Compact, Organized, Enterprise-Grade SaaS Dashboard Design
 */

:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --sidebar-width: 230px;
    --header-height: 52px;
    --bg-light: #f8fafc;
    --bg-card: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --border-light: #f1f5f9;
    --font-base: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Inter", sans-serif;
}

body {
    font-family: var(--font-base);
    background-color: var(--bg-light);
    color: var(--text-main);
    font-size: 0.8125rem; /* 13px base for compact data-dense UI */
    line-height: 1.4;
    overflow-x: hidden;
}

/* Custom Slim Scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: #f1f5f9;
}
::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ─────────────────────────────────────────────────────────────────────────────
 * Sidebar Navigation
 * ───────────────────────────────────────────────────────────────────────────── */
#sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    background-color: #0b1120;
    color: #f8fafc;
    z-index: 1040;
    transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1), transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    border-right: 1px solid #1e293b;
    overflow-y: auto;
    overflow-x: hidden;
}

#sidebar .sidebar-brand {
    padding: 0.85rem 1.15rem;
    font-size: 0.95rem;
    font-weight: 700;
    color: #fff;
    border-bottom: 1px solid #1e293b;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    min-height: var(--header-height);
}

#sidebar .sidebar-brand i {
    font-size: 1.25rem;
}

#sidebar .sidebar-nav {
    padding: 0.5rem 0.6rem;
    flex-grow: 1;
}

#sidebar .nav-link {
    color: #94a3b8;
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    border-radius: 6px;
    margin-bottom: 2px;
    transition: all 0.15s ease-in-out;
    text-decoration: none;
    white-space: nowrap;
}

#sidebar .nav-link:hover {
    color: #f8fafc;
    background: rgba(255, 255, 255, 0.06);
}

#sidebar .nav-link.active {
    color: #ffffff;
    background: #2563eb;
    font-weight: 600;
}

#sidebar .nav-link i {
    font-size: 0.95rem;
    width: 1.1rem;
    text-align: center;
    flex-shrink: 0;
}

/* ─────────────────────────────────────────────────────────────────────────────
 * Main Content Area & Topbar
 * ───────────────────────────────────────────────────────────────────────────── */
#main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    padding: 0.85rem 1.25rem 2.5rem 1.25rem;
    transition: margin-left 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─────────────────────────────────────────────────────────────────────────────
 * Desktop Collapsed Sidebar State (≥ 992px)
 * ───────────────────────────────────────────────────────────────────────────── */
@media (min-width: 992px) {
    body.sidebar-collapsed #sidebar {
        width: 68px;
    }
    body.sidebar-collapsed #sidebar .sidebar-brand {
        padding: 0.85rem 0.5rem;
        justify-content: center !important;
    }
    body.sidebar-collapsed #sidebar .brand-text {
        display: none !important;
    }
    body.sidebar-collapsed #sidebar .sidebar-nav {
        padding: 0.5rem 0.35rem;
    }
    body.sidebar-collapsed #sidebar .nav-link {
        justify-content: center;
        padding: 0.65rem 0;
        gap: 0;
        position: relative;
    }
    body.sidebar-collapsed #sidebar .nav-link .nav-text {
        display: none !important;
    }
    body.sidebar-collapsed #sidebar .nav-link i {
        font-size: 1.15rem;
        width: auto;
        margin: 0;
    }
    body.sidebar-collapsed #sidebar .sidebar-footer {
        display: none !important;
    }
    body.sidebar-collapsed #main-content {
        margin-left: 68px;
    }
}

/* ─────────────────────────────────────────────────────────────────────────────
 * Mobile Off-Canvas Sidebar (< 992px)
 * ───────────────────────────────────────────────────────────────────────────── */
@media (max-width: 991.98px) {
    #sidebar {
        width: 260px;
        max-width: 85vw;
        transform: translateX(-100%);
        z-index: 1050;
    }
    #sidebar.show {
        transform: translateX(0);
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
    }
    #main-content {
        margin-left: 0 !important;
        padding: 0.65rem 0.75rem 2.5rem 0.75rem;
    }
    body.sidebar-open-mobile {
        overflow: hidden;
    }
}

/* Mobile Sidebar Backdrop */
.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(2px);
    z-index: 1045;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}
.sidebar-backdrop.show {
    opacity: 1;
    pointer-events: auto;
}

.top-navbar {
    height: var(--header-height);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    margin-bottom: 0.85rem;
    border-radius: 0.5rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.top-navbar h5 {
    font-size: 0.95rem;
    font-weight: 700;
}

/* ─────────────────────────────────────────────────────────────────────────────
 * Cards & Panels
 * ───────────────────────────────────────────────────────────────────────────── */
.card {
    border: 1px solid var(--border-color) !important;
    border-radius: 0.5rem;
    background-color: var(--bg-card);
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04) !important;
}

.card-header {
    background-color: #fafbfc;
    border-bottom: 1px solid var(--border-color);
    padding: 0.55rem 0.85rem;
    font-size: 0.8rem;
    font-weight: 600;
}

.card-body {
    padding: 0.75rem 0.85rem;
}

.card-footer {
    border-top: 1px solid var(--border-color);
    padding: 0.45rem 0.85rem;
    background: #fafbfc;
}

/* ─────────────────────────────────────────────────────────────────────────────
 * Compact Stat Cards
 * ───────────────────────────────────────────────────────────────────────────── */
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 0.65rem 0.85rem;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    cursor: pointer;
    position: relative;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
    height: 100%;
}

.stat-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.07);
    border-color: #cbd5e1;
}

.stat-card .stat-icon {
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
}

.stat-card .stat-title {
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 0.15rem;
}

.stat-card .stat-value {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.15;
}

.stat-card small {
    font-size: 0.72rem;
    color: #64748b;
}

/* Metric List Rows (for clean Dashboard breakdown) */
.metric-row-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.45rem 0.65rem;
    border-radius: 5px;
    margin-bottom: 0.25rem;
    transition: background 0.15s;
    cursor: pointer;
    text-decoration: none;
    border: 1px solid transparent;
}

.metric-row-item:hover {
    background-color: #f1f5f9;
    border-color: #e2e8f0;
}

.metric-row-item .metric-label {
    font-size: 0.78rem;
    font-weight: 500;
    color: #334155;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.metric-row-item .metric-badge {
    font-size: 0.78rem;
    font-weight: 700;
    padding: 0.15rem 0.45rem;
    border-radius: 4px;
}

/* ─────────────────────────────────────────────────────────────────────────────
 * Sleek Upload Banner
 * ───────────────────────────────────────────────────────────────────────────── */
.upload-strip {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 0.55rem 0.85rem;
    margin-bottom: 0.75rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}

.upload-strip h6 {
    font-size: 0.825rem;
    font-weight: 600;
    margin-bottom: 0.1rem;
}

.upload-strip p {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-bottom: 0;
}

/* ─────────────────────────────────────────────────────────────────────────────
 * Compact Data Tables
 * ───────────────────────────────────────────────────────────────────────────── */
.table-responsive {
    border-radius: 0.375rem;
    max-height: 65vh;
}

.table-custom {
    margin-bottom: 0;
    width: 100%;
}

.table-custom thead th {
    background-color: #f8fafc !important;
    color: #475569;
    font-weight: 600;
    font-size: 0.69rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.45rem 0.55rem;
    border-bottom: 1px solid var(--border-color) !important;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 5;
}

.table-custom tbody td {
    padding: 0.38rem 0.55rem;
    font-size: 0.78rem;
    vertical-align: middle;
    white-space: nowrap;
    border-bottom: 1px solid #f1f5f9;
}

.table-hover tbody tr:hover td {
    background-color: #f8fafc;
}

/* Monospace text for keys */
.font-monospace-code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.72rem;
    background: #f1f5f9;
    color: #334155;
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    border: 1px solid #e2e8f0;
}

/* ─────────────────────────────────────────────────────────────────────────────
 * Refined Micro Badges
 * ───────────────────────────────────────────────────────────────────────────── */
.badge-status {
    font-size: 0.68rem;
    padding: 0.16rem 0.45rem;
    font-weight: 500;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    line-height: 1.2;
    white-space: nowrap;
}

.badge-status i {
    font-size: 0.72rem;
}

/* Status: Existing in Grades Migrated in SIS */
.status-existing {
    background-color: #ecfeff;
    color: #0e7490;
    border: 1px solid #bae6fd;
}

/* Status: MISSING */
.status-missing {
    background-color: #fffbeb;
    color: #b45309;
    border: 1px solid #fed7aa;
}

/* Migration Status: Migrated */
.mig-status-migrated {
    background-color: #f0fdf4;
    color: #15803d;
    border: 1px solid #bbf7d0;
}

/* Migration Status: Duplicate Semester */
.mig-status-duplicate-semester {
    background-color: #f5f3ff;
    color: #6d28d9;
    border: 1px solid #ddd6fe;
}

/* Migration Status: Student not Present in SIS */
.mig-status-not-present-sis {
    background-color: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

/* Migration Status: Student Not Uploaded in SIS */
.mig-status-not-uploaded-sis {
    background-color: #fff7ed;
    color: #c2410c;
    border: 1px solid #fed7aa;
}

/* Migration Status: Different College Already Present In Session */
.mig-status-diff-college {
    background-color: #f8fafc;
    color: #475569;
    border: 1px solid #cbd5e1;
}

/* Checkers */
.checker-true {
    background-color: #f0fdf4;
    color: #16a34a;
    font-weight: 600;
    border: 1px solid #bbf7d0;
}

.checker-false {
    background-color: #fef2f2;
    color: #dc2626;
    font-weight: 600;
    border: 1px solid #fecaca;
}

.checker-unresolved {
    background-color: #f8fafc;
    color: #64748b;
    font-style: italic;
    border: 1px solid #e2e8f0;
}

/* SIS Match Status */
.sis-auto {
    background-color: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
}

.sis-manual {
    background-color: #f0fdf4;
    color: #15803d;
    border: 1px solid #bbf7d0;
}

.sis-conflict {
    background-color: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.sis-no-record {
    background-color: #f8fafc;
    color: #64748b;
    border: 1px solid #cbd5e1;
}

/* ─────────────────────────────────────────────────────────────────────────────
 * Form Controls & Buttons
 * ───────────────────────────────────────────────────────────────────────────── */
.form-control, .form-select {
    font-size: 0.78rem;
    border-color: #cbd5e1;
    border-radius: 5px;
}

.form-control:focus, .form-select:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

.form-control-sm, .form-select-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.78rem;
    height: 30px;
}

.input-group-sm > .form-control,
.input-group-sm > .form-select,
.input-group-sm > .input-group-text,
.input-group-sm > .btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.78rem;
    height: 30px;
}

.btn-sm {
    padding: 0.25rem 0.55rem;
    font-size: 0.76rem;
    border-radius: 5px;
    font-weight: 500;
}

.btn-group-sm > .btn {
    padding: 0.2rem 0.45rem;
    font-size: 0.72rem;
}

/* Pagination */
.pagination-sm .page-link {
    padding: 0.2rem 0.5rem;
    font-size: 0.75rem;
}

/* Loading Overlay */
#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(2px);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    color: #fff;
}

#loading-overlay .spinner-border {
    width: 2.5rem;
    height: 2.5rem;
    border-width: 0.2em;
}

/* Toast Container */
.toast-container {
    z-index: 1080;
}
.toast {
    font-size: 0.8rem;
    border-radius: 6px;
}

/* ─────────────────────────────────────────────────────────────────────────────
 * Check Migrated Grades Modal Enhancements
 * ───────────────────────────────────────────────────────────────────────────── */
#modal-check-migrated-grades .modal-header {
    background-color: #fff7ed;
    border-bottom-color: #fed7aa;
    color: #c2410c;
}

#modal-check-migrated-grades .modal-title {
    color: #c2410c;
}

#modal-check-migrated-grades .modal-body .card {
    border-radius: 0.5rem;
}

#modal-check-migrated-grades .modal-body .card.border-success {
    border-color: #bbf7d0 !important;
}

#modal-check-migrated-grades .modal-body .card.border-secondary {
    border-color: #cbd5e1 !important;
}

#modal-check-migrated-grades .modal-body .table th {
    font-size: 0.69rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

#modal-check-migrated-grades .modal-body .table td {
    font-size: 0.78rem;
}

.cmg-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2rem 1rem;
    color: #64748b;
}

.cmg-empty-state i {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    opacity: 0.5;
}

/* ─────────────────────────────────────────────────────────────────────────────
 * Comprehensive Mobile UI/UX Enhancements (< 768px and < 576px)
 * ───────────────────────────────────────────────────────────────────────────── */
@media (max-width: 767.98px) {
    /* Navbar compact spacing */
    .top-navbar {
        padding: 0.4rem 0.65rem;
        margin-bottom: 0.65rem;
    }
    #page-title {
        font-size: 0.88rem !important;
    }
    
    /* Stat cards */
    .stat-card {
        padding: 0.6rem 0.75rem;
    }
    .stat-card .stat-value {
        font-size: 1.25rem;
    }
    .stat-card .stat-icon {
        width: 32px;
        height: 32px;
        min-width: 32px;
        font-size: 1rem;
    }

    /* Action buttons in toolbars */
    .btn-sm {
        padding: 0.28rem 0.55rem;
        font-size: 0.75rem;
    }

    /* Modal responsiveness */
    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }
    .modal-header {
        padding: 0.65rem 0.85rem;
    }
    .modal-body {
        padding: 0.85rem;
    }
    .modal-footer {
        padding: 0.5rem 0.85rem;
        flex-wrap: wrap;
        gap: 0.35rem;
    }

    /* Card footers and pagination */
    .card-footer {
        padding: 0.5rem 0.65rem;
        flex-direction: column;
        align-items: center !important;
        gap: 0.4rem;
        text-align: center;
    }
    .pagination {
        flex-wrap: wrap;
        justify-content: center;
        gap: 2px;
    }
    .pagination-sm .page-link {
        padding: 0.25rem 0.5rem;
        min-width: 28px;
        text-align: center;
    }

    /* Tables: horizontal scroll touch optimization */
    .table-responsive {
        max-height: 55vh;
        -webkit-overflow-scrolling: touch;
    }
}

@media (max-width: 575.98px) {
    /* Navbar ultra compact */
    .top-navbar {
        padding: 0.35rem 0.5rem;
    }
    #page-title {
        font-size: 0.82rem !important;
    }

    /* Upload strip wraps cleanly */
    .upload-strip {
        flex-direction: column;
        align-items: stretch !important;
        gap: 0.5rem;
        padding: 0.65rem;
    }
    .upload-strip form {
        flex-direction: column;
        align-items: stretch !important;
        width: 100%;
        gap: 0.35rem;
    }
    .upload-strip form input[type="file"] {
        max-width: 100% !important;
        width: 100%;
    }
    .upload-strip form button {
        width: 100%;
    }

    /* Metric items */
    .metric-row-item {
        padding: 0.4rem 0.5rem;
    }
    .metric-row-item .metric-label {
        font-size: 0.75rem;
    }
    .metric-row-item .metric-label small {
        font-size: 0.68rem;
    }
    .metric-row-item .metric-badge {
        font-size: 0.72rem;
    }

    /* Filter rows stack cleanly */
    .card-body .row.g-1 > div {
        margin-bottom: 0.25rem;
    }

    /* Danger zone cards */
    #view-danger-zone .card-body .row.align-items-center > div {
        text-align: start !important;
    }
    #view-danger-zone .card-body .row.align-items-center button {
        width: 100%;
        margin-top: 0.5rem;
    }
}
