/* ============================================================
   EasySchool ERP — Apple-inspired Design System
   ============================================================ */

:root {
    --brand-primary:    #007AFF;
    --brand-secondary:  #34C759;
    --brand-danger:     #FF3B30;
    --brand-warning:    #FF9500;
    --brand-info:       #5AC8FA;

    --sidebar-width:    240px;
    --sidebar-bg:       #FFFFFF;
    --sidebar-border:   rgba(60,60,67,.12);
    --sidebar-hover:    rgba(0,122,255,.07);
    --sidebar-active:   rgba(0,122,255,.12);
    --sidebar-text:     #3C3C43;
    --sidebar-text-dim: #8E8E93;
    --topbar-height:    60px;

    --surface:          #F2F2F7;
    --card-bg:          #FFFFFF;
    --label-primary:    #1C1C1E;
    --label-secondary:  #3C3C43;
    --label-tertiary:   #8E8E93;
    --separator:        rgba(60,60,67,.12);

    --radius-sm:  8px;
    --radius-md:  12px;
    --radius-lg:  16px;

    --shadow-sm:  0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md:  0 4px 12px rgba(0,0,0,.08), 0 2px 4px rgba(0,0,0,.04);
    --shadow-lg:  0 12px 32px rgba(0,0,0,.10), 0 4px 8px rgba(0,0,0,.04);

    --font-system: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI",
                   Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI",
                    Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ── Base ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: var(--font-system);
    background: var(--surface);
    color: var(--label-primary);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ── Layout ───────────────────────────────────────────────── */
#wrapper { display: flex; min-height: 100vh; }

#sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    min-height: 100vh;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    transition: width .25s cubic-bezier(.4,0,.2,1),
                min-width .25s cubic-bezier(.4,0,.2,1);
    flex-shrink: 0;
    position: sticky;
    top: 0;
    align-self: flex-start;
    max-height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
}

#sidebar.collapsed { width: 64px !important; min-width: 64px !important; }
#sidebar.collapsed .sidebar-label { display: none !important; }
#sidebar.collapsed .sidebar-section-label { display: none !important; }
#sidebar.collapsed .nav-link { justify-content: center; padding: .55rem .5rem; }
#sidebar.collapsed .sidebar-brand { justify-content: center; }
#sidebar.collapsed .sidebar-user { justify-content: center; }

#page-content-wrapper {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: var(--surface);
}

/* ── Topbar ───────────────────────────────────────────────── */
.navbar {
    height: var(--topbar-height);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    background: rgba(242,242,247,.85) !important;
    border-bottom: 1px solid var(--separator);
    box-shadow: none !important;
}

/* ── Sidebar Nav ──────────────────────────────────────────── */
.sidebar-divider {
    height: 1px;
    background: var(--sidebar-border);
    margin: 0;
}

.sidebar-section-label {
    display: block;
    padding: 0 .6rem;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: .7px;
    color: var(--sidebar-text-dim);
    text-transform: uppercase;
}

#sidebar .nav-link {
    color: var(--sidebar-text);
    border-radius: var(--radius-sm);
    margin: 1px 6px;
    padding: .48rem .7rem;
    transition: background .15s ease, color .15s ease;
    white-space: nowrap;
    overflow: hidden;
    font-size: 13.5px;
    font-weight: 450;
}
#sidebar .nav-link:hover  { background: var(--sidebar-hover); color: var(--brand-primary); }
#sidebar .nav-link.active {
    background: var(--sidebar-active);
    color: var(--brand-primary);
    font-weight: 600;
}
#sidebar .nav-link i { font-size: 15px; flex-shrink: 0; }

/* ── Cards ────────────────────────────────────────────────── */
.card {
    background: var(--card-bg);
    border: none !important;
    border-radius: var(--radius-md) !important;
    box-shadow: var(--shadow-sm) !important;
}

.card-header {
    border-radius: var(--radius-md) var(--radius-md) 0 0 !important;
    border-bottom: 1px solid var(--separator) !important;
    background: transparent !important;
    padding: 1rem 1.25rem;
    font-weight: 600;
    font-size: 15px;
}

.card-body { padding: 1.25rem; }

/* hover lift */
.card-hover {
    transition: box-shadow .2s ease, transform .2s ease;
    cursor: default;
}
.card-hover:hover {
    box-shadow: var(--shadow-md) !important;
    transform: translateY(-2px);
}

/* KPI stat cards */
.kpi-card {
    transition: box-shadow .2s ease, transform .2s ease;
}
.kpi-card:hover {
    box-shadow: var(--shadow-md) !important;
    transform: translateY(-2px);
}

.kpi-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
}

.kpi-value {
    font-family: var(--font-display);
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -.5px;
    color: var(--label-primary);
    line-height: 1;
}

.kpi-label {
    font-size: 13px;
    color: var(--label-tertiary);
    font-weight: 500;
    margin-top: 2px;
}

/* ── Tables ───────────────────────────────────────────────── */
.table {
    font-size: 14px;
    color: var(--label-primary);
    --bs-table-bg: transparent;
    --bs-table-striped-bg: rgba(0,0,0,.015);
    --bs-table-hover-bg:  rgba(0,122,255,.04);
}

.table thead th {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: var(--label-tertiary);
    border-top: none;
    border-bottom: 1px solid var(--separator) !important;
    padding: .6rem 1rem;
}

.table tbody td {
    padding: .75rem 1rem;
    vertical-align: middle;
    border-color: var(--separator);
}

.table tbody tr:hover { background: rgba(0,122,255,.04); }

/* table inside card: remove outer border */
.card > .table,
.card > .table-responsive > .table {
    margin: 0;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
}

/* ── Badges ───────────────────────────────────────────────── */
.badge {
    font-weight: 500;
    font-size: 12px;
    padding: .3em .65em;
    border-radius: 6px;
}

.badge.bg-primary   { background: rgba(0,122,255,.15)   !important; color: #007AFF   !important; }
.badge.bg-success   { background: rgba(52,199,89,.15)   !important; color: #28A745   !important; }
.badge.bg-danger    { background: rgba(255,59,48,.12)   !important; color: #DC3545   !important; }
.badge.bg-warning   { background: rgba(255,149,0,.15)   !important; color: #B86E00   !important; }
.badge.bg-secondary { background: rgba(142,142,147,.15) !important; color: #636366   !important; }
.badge.bg-info      { background: rgba(90,200,250,.15)  !important; color: #0891B2   !important; }

/* ── Forms ────────────────────────────────────────────────── */
.form-label {
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 4px;
    color: var(--label-secondary);
}

.form-control,
.form-select {
    border-radius: var(--radius-sm);
    border: 1px solid rgba(60,60,67,.2);
    background: #FFFFFF;
    font-size: 15px;
    padding: .5rem .875rem;
    color: var(--label-primary);
    transition: border-color .15s ease, box-shadow .15s ease;
}

.form-control::placeholder { color: rgba(60,60,67,.35); }

.form-control:focus,
.form-select:focus {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(0,122,255,.18);
    outline: none;
}

textarea.form-control { resize: vertical; min-height: 90px; }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 14px;
    padding: .45rem 1rem;
    transition: all .15s ease;
    border: none;
}

.btn-primary {
    background: var(--brand-primary);
    color: #fff;
    box-shadow: 0 2px 6px rgba(0,122,255,.3);
}
.btn-primary:hover {
    background: #0062CC;
    box-shadow: 0 4px 12px rgba(0,122,255,.35);
    transform: translateY(-1px);
    color: #fff;
}
.btn-primary:active { transform: none; box-shadow: 0 1px 3px rgba(0,122,255,.2); }

.btn-success  { background: var(--brand-secondary); color: #fff; }
.btn-success:hover  { background: #28A745; color: #fff; }

.btn-danger   { background: var(--brand-danger); color: #fff; }
.btn-danger:hover   { background: #CC2E24; color: #fff; }

.btn-outline-primary {
    border: 1.5px solid var(--brand-primary);
    color: var(--brand-primary);
    background: transparent;
}
.btn-outline-primary:hover {
    background: rgba(0,122,255,.08);
    border-color: var(--brand-primary);
    color: var(--brand-primary);
}

.btn-light {
    background: rgba(60,60,67,.08);
    color: var(--label-primary);
    border: none;
}
.btn-light:hover { background: rgba(60,60,67,.14); color: var(--label-primary); }

.btn-sm { font-size: 12px; padding: .3rem .7rem; }
.btn-lg { font-size: 16px; padding: .6rem 1.4rem; }

/* ── Modals ───────────────────────────────────────────────── */
.modal-content {
    border: none !important;
    border-radius: var(--radius-lg) !important;
    box-shadow: var(--shadow-lg) !important;
    overflow: hidden;
}

.modal-header {
    border-bottom: 1px solid var(--separator);
    padding: 1.1rem 1.5rem;
}

.modal-footer {
    border-top: 1px solid var(--separator);
    padding: .875rem 1.5rem;
    gap: .5rem;
}

.modal-title { font-weight: 700; font-size: 17px; }

/* ── Page header ──────────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    padding-bottom: .75rem;
    border-bottom: 1px solid var(--separator);
}

.page-header h4 {
    margin: 0;
    font-weight: 700;
    font-family: var(--font-display);
    font-size: 22px;
    letter-spacing: -.3px;
}

/* ── Section headings ─────────────────────────────────────── */
h1, h2, h3, h4, h5 {
    font-family: var(--font-display);
    font-weight: 700;
    letter-spacing: -.2px;
}

/* ── Alerts ───────────────────────────────────────────────── */
.alert {
    border: none;
    border-radius: var(--radius-md);
    font-size: 14px;
    padding: .75rem 1rem;
}
.alert-success  { background: rgba(52,199,89,.12);   color: #1A7A32; }
.alert-danger   { background: rgba(255,59,48,.10);   color: #A8201A; }
.alert-warning  { background: rgba(255,149,0,.12);   color: #7A4E00; }
.alert-info     { background: rgba(90,200,250,.12);  color: #0077A3; }

/* ── Nav tabs ─────────────────────────────────────────────── */
.nav-tabs { border-bottom: 1px solid var(--separator); }
.nav-tabs .nav-link {
    border: none;
    color: var(--label-tertiary);
    font-weight: 500;
    font-size: 14px;
    padding: .6rem 1rem;
    border-radius: 0;
}
.nav-tabs .nav-link:hover { color: var(--brand-primary); background: transparent; }
.nav-tabs .nav-link.active {
    color: var(--brand-primary);
    background: transparent;
    border-bottom: 2px solid var(--brand-primary);
    font-weight: 600;
}

/* ── Pagination ───────────────────────────────────────────── */
.pagination .page-link {
    border: none;
    border-radius: var(--radius-sm) !important;
    margin: 0 2px;
    color: var(--brand-primary);
    font-size: 14px;
    padding: .4rem .75rem;
}
.pagination .page-item.active .page-link {
    background: var(--brand-primary);
    color: #fff;
    box-shadow: 0 2px 6px rgba(0,122,255,.3);
}
.pagination .page-link:hover { background: rgba(0,122,255,.08); color: var(--brand-primary); }

/* ── Progress bars ────────────────────────────────────────── */
.progress { border-radius: 999px; background: rgba(60,60,67,.1); height: 6px; }
.progress-bar { border-radius: 999px; }

/* ── Avatar initials ──────────────────────────────────────── */
.avatar-circle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 13px;
    flex-shrink: 0;
}

/* ── Utility ──────────────────────────────────────────────── */
.text-muted { color: var(--label-tertiary) !important; }
.text-primary { color: var(--brand-primary) !important; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.fs-13 { font-size: 13px; }
.fs-12 { font-size: 12px; }
.rounded-12 { border-radius: 12px !important; }
.rounded-8  { border-radius: 8px !important; }
.bg-surface { background: var(--surface) !important; }

/* ── Alert compact ────────────────────────────────────────── */
.alert-sm { font-size: 13px; padding: .5rem .875rem; }

/* ── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(60,60,67,.2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(60,60,67,.35); }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 768px) {
    #sidebar {
        position: fixed;
        z-index: 1040;
        transform: translateX(-100%);
        transition: transform .25s cubic-bezier(.4,0,.2,1);
    }
    #sidebar.show { transform: translateX(0); }
    #page-content-wrapper { margin-left: 0 !important; }

    .kpi-value { font-size: 22px; }
    .page-header h4 { font-size: 18px; }
}

/* ── Print ────────────────────────────────────────────────── */
@media print {
    #sidebar, .navbar, .btn, .no-print, .alert { display: none !important; }
    #page-content-wrapper { margin: 0 !important; }
    body { background: #fff; }
    .card {
        box-shadow: none !important;
        border: 1px solid #dee2e6 !important;
        break-inside: avoid;
    }
}
