/* ==========================================================================
   School Management System - application styles
   No build step: plain CSS served from /assets/css/app.css
   ========================================================================== */

:root {
    --sidebar-width: 250px;
    --sidebar-bg: #101a35;
    --sidebar-bg-hover: #1a2950;
    --sidebar-text: #9fb0d0;
    --sidebar-text-active: #ffffff;
    --sidebar-accent: #3b82f6;

    --topbar-bg: #ffffff;
    --bg: #f4f6fb;
    --surface: #ffffff;
    --border: #e3e8f0;
    --text: #1b2437;
    --text-muted: #67738a;

    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;
    --info: #0891b2;

    --radius: 10px;
    --shadow: 0 1px 3px rgba(16, 26, 53, .08), 0 4px 14px rgba(16, 26, 53, .05);
    --font: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0 0 .5rem; font-weight: 600; line-height: 1.25; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }

p { margin: 0 0 1rem; }

/* ---------------------------------------------------------------- layout */

.app { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    position: fixed;
    inset: 0 auto 0 0;
    display: flex;
    flex-direction: column;
    z-index: 40;
    transition: transform .2s ease;
}

.sidebar__brand {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: 1.1rem 1.25rem;
    color: #fff;
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: .01em;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.sidebar__brand-mark {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--sidebar-accent), #60a5fa);
    display: grid;
    place-items: center;
    font-size: .9rem;
    font-weight: 700;
    color: #fff;
}

.sidebar__nav { flex: 1; overflow-y: auto; padding: .75rem 0; }

.sidebar__section {
    padding: .9rem 1.25rem .35rem;
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: #61729a;
}

.sidebar__link {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .6rem 1.25rem;
    color: var(--sidebar-text);
    font-size: .92rem;
    border-left: 3px solid transparent;
}

.sidebar__link:hover { background: var(--sidebar-bg-hover); color: #fff; text-decoration: none; }

.sidebar__link.is-active {
    background: var(--sidebar-bg-hover);
    color: var(--sidebar-text-active);
    border-left-color: var(--sidebar-accent);
    font-weight: 600;
}

.sidebar__icon { width: 18px; text-align: center; opacity: .9; }

.sidebar__footer {
    padding: .9rem 1.25rem;
    border-top: 1px solid rgba(255, 255, 255, .08);
    font-size: .78rem;
    color: #61729a;
}

.main {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    background: var(--topbar-bg);
    border-bottom: 1px solid var(--border);
    padding: .75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 30;
}

.topbar__crumb { font-size: .85rem; color: var(--text-muted); }
.topbar__crumb strong { color: var(--text); font-weight: 600; }

.topbar__user { display: flex; align-items: center; gap: .75rem; }

.avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 600;
    font-size: .85rem;
    flex: none;
}

.topbar__name { font-size: .88rem; font-weight: 600; }
.topbar__role { font-size: .74rem; color: var(--text-muted); }

.menu-toggle {
    display: none;
    background: none;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: .35rem .55rem;
    font-size: 1.1rem;
    cursor: pointer;
    color: var(--text);
}

.content { padding: 1.5rem; flex: 1; }

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}

.page-header__subtitle { color: var(--text-muted); font-size: .9rem; margin: 0; }

/* ----------------------------------------------------------------- cards */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 1.25rem;
}

.card__header {
    padding: .9rem 1.15rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.card__body { padding: 1.15rem; }
.card__body--flush { padding: 0; }

/* ----------------------------------------------------------------- stats */

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1rem 1.15rem;
    display: flex;
    align-items: center;
    gap: .9rem;
}

.stat__icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    font-size: 1.15rem;
    flex: none;
}

.stat__icon--blue { background: #e4edff; color: var(--primary); }
.stat__icon--green { background: #e3f7ea; color: var(--success); }
.stat__icon--amber { background: #fdf0e0; color: var(--warning); }
.stat__icon--cyan { background: #e0f5f9; color: var(--info); }

.stat__value { font-size: 1.5rem; font-weight: 700; line-height: 1.1; }
.stat__label { font-size: .8rem; color: var(--text-muted); }

/* ---------------------------------------------------------------- tables */

.table-wrap { overflow-x: auto; }

table.table { width: 100%; border-collapse: collapse; font-size: .9rem; }

.table th, .table td {
    padding: .7rem 1.15rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.table thead th {
    background: #f8fafd;
    font-size: .74rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-muted);
    font-weight: 600;
    white-space: nowrap;
}

.table tbody tr:hover { background: #f9fbff; }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .actions { text-align: right; white-space: nowrap; }

.table-empty {
    padding: 2.5rem 1rem;
    text-align: center;
    color: var(--text-muted);
}

/* ---------------------------------------------------------------- forms */

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: .9rem 1rem;
}

.form-group { display: flex; flex-direction: column; gap: .3rem; margin-bottom: .9rem; }
.form-grid .form-group { margin-bottom: 0; }

label { font-size: .82rem; font-weight: 600; color: #3d4a63; }

label .req { color: var(--danger); }

input[type=text], input[type=email], input[type=password], input[type=date],
input[type=number], input[type=time], input[type=search], input[type=tel],
select, textarea {
    width: 100%;
    padding: .55rem .7rem;
    border: 1px solid #cfd7e5;
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    font-family: inherit;
    font-size: .92rem;
    transition: border-color .15s, box-shadow .15s;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .15);
}

textarea { min-height: 84px; resize: vertical; }

.form-hint { font-size: .76rem; color: var(--text-muted); }
.form-error { font-size: .78rem; color: var(--danger); }

.form-row { display: flex; gap: .75rem; flex-wrap: wrap; align-items: flex-end; }
.form-row .form-group { margin-bottom: 0; flex: 1; min-width: 160px; }

.filters {
    display: flex;
    gap: .6rem;
    flex-wrap: wrap;
    align-items: flex-end;
}

.filters .form-group { margin-bottom: 0; min-width: 150px; }

/* --------------------------------------------------------------- buttons */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    padding: .55rem .95rem;
    border: 1px solid transparent;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    font-size: .88rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s, border-color .15s;
}

.btn:hover { background: var(--primary-dark); text-decoration: none; }
.btn:disabled { opacity: .6; cursor: not-allowed; }

.btn--secondary { background: #fff; color: var(--text); border-color: #cfd7e5; }
.btn--secondary:hover { background: #f4f6fb; }

.btn--success { background: var(--success); }
.btn--success:hover { background: #15803d; }

.btn--danger { background: var(--danger); }
.btn--danger:hover { background: #b91c1c; }

.btn--ghost { background: transparent; color: var(--primary); padding: .35rem .5rem; }
.btn--ghost:hover { background: #eef4ff; }

.btn--sm { padding: .32rem .6rem; font-size: .8rem; border-radius: 7px; }

.btn--block { width: 100%; }

/* ---------------------------------------------------------------- badges */

.badge {
    display: inline-block;
    padding: .18rem .55rem;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 600;
    line-height: 1.5;
    white-space: nowrap;
}

.badge--green { background: #e3f7ea; color: #15803d; }
.badge--red { background: #fdeaea; color: #b91c1c; }
.badge--amber { background: #fdf0e0; color: #b45309; }
.badge--blue { background: #e4edff; color: #1d4ed8; }
.badge--gray { background: #eef1f6; color: #4b5565; }
.badge--cyan { background: #e0f5f9; color: #0e7490; }

/* ---------------------------------------------------------------- alerts */

.alert {
    padding: .75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: .9rem;
    border: 1px solid transparent;
}

.alert--success { background: #e9f9ef; border-color: #b9e8c9; color: #166534; }
.alert--error { background: #fdecec; border-color: #f6c7c7; color: #991b1b; }
.alert--info { background: #e6f6fa; border-color: #b9e3ec; color: #155e75; }
.alert--warning { background: #fdf4e5; border-color: #f6dfb5; color: #92400e; }

/* -------------------------------------------------------------- utility */

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1.25rem; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: .85rem; }
.text-right { text-align: right; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.mono { font-family: Consolas, "SF Mono", Menlo, monospace; font-size: .88em; }

/* --------------------------------------------------------- modal/dialog */

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .5);
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding: 3rem 1rem;
    z-index: 50;
    overflow-y: auto;
}

.modal-backdrop.is-open { display: flex; }

.modal {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 20px 50px rgba(15, 23, 42, .25);
    width: 100%;
    max-width: 640px;
    animation: pop .15s ease-out;
}

@keyframes pop { from { transform: translateY(-8px); opacity: 0; } }

.modal__header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal__body { padding: 1.25rem; }
.modal__footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: .6rem;
}

.modal__close { background: none; border: 0; font-size: 1.3rem; cursor: pointer; color: var(--text-muted); line-height: 1; }

/* ----------------------------------------------------------- auth pages */

.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #101a35 0%, #1e3a8a 55%, #2563eb 100%);
    padding: 1.5rem;
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, .3);
    padding: 2rem;
}

.auth-card__brand { display: flex; align-items: center; gap: .7rem; margin-bottom: 1.25rem; }
.auth-card__title { font-size: 1.25rem; margin: 0; }
.auth-card__subtitle { color: var(--text-muted); font-size: .86rem; margin: .2rem 0 1.25rem; }

/* ------------------------------------------------------------- printing */

.print-only { display: none; }

@media print {
    .sidebar, .topbar, .no-print { display: none !important; }
    .main { margin-left: 0; }
    .content { padding: 0; }
    .card { box-shadow: none; border: 0; }
    body { background: #fff; }
    .print-only { display: block; }
}

/* ----------------------------------------------------------- responsive */

@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.is-open { transform: translateX(0); }
    .main { margin-left: 0; }
    .menu-toggle { display: block; }
    .content { padding: 1rem; }
}

/* ---------------------------------------------------------- breadcrumbs */

.breadcrumbs {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .4rem;
    font-size: .85rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.breadcrumbs a { color: var(--text-muted); }
.breadcrumbs a:hover { color: var(--primary); }
.breadcrumbs .sep { color: #b3bccd; user-select: none; }
.breadcrumbs [aria-current="page"] { color: var(--text); font-weight: 600; }

/* ------------------------------------------------- topbar profile menu */

.dropdown { position: relative; }

.dropdown__toggle {
    display: flex;
    align-items: center;
    gap: .6rem;
    background: none;
    border: 1px solid transparent;
    border-radius: 10px;
    padding: .3rem .5rem;
    cursor: pointer;
    font-family: inherit;
    color: var(--text);
}

.dropdown__toggle:hover,
.dropdown__toggle[aria-expanded="true"] {
    background: #f2f5fb;
    border-color: var(--border);
}

.dropdown__meta { display: flex; flex-direction: column; line-height: 1.25; text-align: left; }
.dropdown__caret { font-size: .7rem; color: var(--text-muted); }

.dropdown__menu {
    position: absolute;
    right: 0;
    top: calc(100% + .45rem);
    min-width: 220px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 14px 34px rgba(16, 26, 53, .16);
    padding: .4rem;
    z-index: 60;
    display: flex;
    flex-direction: column;
}

.dropdown__menu[hidden] { display: none; }

.dropdown__item {
    display: block;
    width: 100%;
    text-align: left;
    padding: .5rem .7rem;
    border: 0;
    border-radius: 7px;
    background: none;
    font-family: inherit;
    font-size: .88rem;
    color: var(--text);
    cursor: pointer;
    text-decoration: none;
}

.dropdown__item:hover { background: #f2f5fb; text-decoration: none; }
.dropdown__item--danger { color: var(--danger); }
.dropdown__item--danger:hover { background: #fdecec; color: var(--danger); }
.dropdown__sep { height: 1px; background: var(--border); margin: .35rem .15rem; }

/* --------------------------------------------------- dashboard / misc UI */

.page-header__actions {
    display: flex;
    align-items: flex-end;
    gap: .75rem;
    flex-wrap: wrap;
}

.page-header__actions form.filters { align-items: flex-end; }
.date-filter .btn { margin-bottom: .1rem; }

/* Row note under a table (totals, today's line, ...) */
.table-note {
    padding: .7rem 1.15rem;
    border-top: 1px solid var(--border);
    font-size: .85rem;
    color: var(--text-muted);
}

.table tfoot td {
    background: #f8fafd;
    font-weight: 600;
    border-top: 1px solid var(--border);
    border-bottom: 0;
}

/* Definition list used by the parent/student summary blocks */
.kv { list-style: none; margin: 0; padding: 0; display: grid; gap: .55rem; }

.kv li {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    font-size: .88rem;
    border-bottom: 1px dashed var(--border);
    padding-bottom: .45rem;
}

.kv li:last-child { border-bottom: 0; padding-bottom: 0; }
.kv li > span:first-child { color: var(--text-muted); }
.kv li > span:last-child { text-align: right; }

/* Alert rows on the dashboard (message + link) */
.alert-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: .6rem;
}

.alert-row:last-child { margin-bottom: 0; }
.alert-row a { white-space: nowrap; }

/* Nested "child" cards inside the parent welcome block */
.child-card { box-shadow: none; }

/* Extra body block separated by a top rule (key dates, totals, ...) */
.card__body--bordered { border-top: 1px solid var(--border); }

/* ----------------------------------------------------------- responsive */

@media (max-width: 900px) {
    .page-header__actions { width: 100%; }
    .date-filter { width: 100%; }
    .date-filter .form-group { flex: 1; min-width: 130px; }
}

@media (max-width: 600px) {
    .dropdown__meta { display: none; }
}

@media (max-width: 480px) {
    .breadcrumbs { display: none; }
    .alert-row { flex-direction: column; align-items: flex-start; gap: .4rem; }
}
