/*
 * AGTS Students Portal - design layer over Bootstrap 5.3.
 *
 * Colours come from the AGTS crest: the royal-blue shield, the red cross, the
 * yellow border and the white book. Phones are the main screen, so the layout
 * is written for them first: a top app bar, a bottom tab bar and an off-canvas
 * menu, becoming a fixed sidebar from 992px up.
 */

:root {
    --agts-blue: #1530c4;
    --agts-blue-rgb: 21, 48, 196;
    --agts-navy: #0b1b6f;
    --agts-navy-2: #0f2590;
    --agts-gold: #f6d31c;
    --agts-gold-deep: #c9a200;
    --agts-red: #d8201b;
    --agts-ink: #0f172a;
    --agts-muted: #64748b;
    --agts-line: #e6e9f2;
    --agts-bg: #f3f5fb;
    --agts-card: #ffffff;
    --agts-radius: 16px;
    --agts-radius-sm: 10px;
    --agts-shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 6px 18px rgba(15, 23, 42, .06);
    --agts-appbar-h: 60px;
    --agts-tabbar-h: 64px;
    --agts-sidebar-w: 264px;

    /* Bootstrap hooks */
    --bs-primary: var(--agts-blue);
    --bs-primary-rgb: var(--agts-blue-rgb);
    --bs-link-color: var(--agts-blue);
    --bs-link-color-rgb: var(--agts-blue-rgb);
    --bs-link-hover-color: var(--agts-navy);
    --bs-danger: var(--agts-red);
    --bs-danger-rgb: 216, 32, 27;
    --bs-body-bg: var(--agts-bg);
    --bs-body-color: var(--agts-ink);
    --bs-border-color: var(--agts-line);
    --bs-border-radius: var(--agts-radius-sm);
    --bs-body-font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

html { -webkit-text-size-adjust: 100%; }
body {
    background: var(--agts-bg);
    min-height: 100vh;
    font-size: .95rem;
    -webkit-tap-highlight-color: transparent;
}

/* ---------- Buttons ---------- */
.btn { border-radius: 12px; font-weight: 600; padding: .6rem 1.1rem; }
.btn-sm { border-radius: 9px; padding: .35rem .75rem; }
.btn-lg { padding: .8rem 1.4rem; }
.btn-primary {
    --bs-btn-bg: var(--agts-blue); --bs-btn-border-color: var(--agts-blue);
    --bs-btn-hover-bg: var(--agts-navy-2); --bs-btn-hover-border-color: var(--agts-navy-2);
    --bs-btn-active-bg: var(--agts-navy); --bs-btn-active-border-color: var(--agts-navy);
    --bs-btn-disabled-bg: var(--agts-blue); --bs-btn-disabled-border-color: var(--agts-blue);
}
.btn-outline-primary {
    --bs-btn-color: var(--agts-blue); --bs-btn-border-color: rgba(var(--agts-blue-rgb), .35);
    --bs-btn-hover-bg: var(--agts-blue); --bs-btn-hover-border-color: var(--agts-blue);
    --bs-btn-active-bg: var(--agts-navy); --bs-btn-active-border-color: var(--agts-navy);
}
.btn-gold {
    --bs-btn-bg: var(--agts-gold); --bs-btn-border-color: var(--agts-gold); --bs-btn-color: var(--agts-navy);
    --bs-btn-hover-bg: #ffe04a; --bs-btn-hover-border-color: #ffe04a; --bs-btn-hover-color: var(--agts-navy);
    --bs-btn-active-bg: var(--agts-gold-deep); --bs-btn-active-border-color: var(--agts-gold-deep);
}
.btn-soft {
    background: rgba(var(--agts-blue-rgb), .08); color: var(--agts-blue); border: 0;
}
.btn-soft:hover, .btn-soft:focus { background: rgba(var(--agts-blue-rgb), .15); color: var(--agts-navy); }
.btn:focus-visible, .form-control:focus, .form-select:focus, .form-check-input:focus {
    box-shadow: 0 0 0 .22rem rgba(var(--agts-blue-rgb), .2);
}
.form-control:focus, .form-select:focus { border-color: rgba(var(--agts-blue-rgb), .55); }
.form-check-input:checked { background-color: var(--agts-blue); border-color: var(--agts-blue); }

/* Inputs large enough to tap and not zoomed by iOS (>=16px). */
.form-control, .form-select { border-radius: 12px; padding: .7rem .9rem; font-size: 1rem; border-color: #d9deea; }
.form-label { font-weight: 600; font-size: .85rem; color: #334155; margin-bottom: .35rem; }

/* ---------- App shell ---------- */
.app-bar {
    position: fixed; inset: 0 0 auto 0; z-index: 1030;
    height: calc(var(--agts-appbar-h) + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) .75rem 0;
    display: flex; align-items: center; gap: .5rem;
    background: linear-gradient(120deg, var(--agts-navy) 0%, var(--agts-blue) 100%);
    color: #fff;
    box-shadow: 0 2px 12px rgba(11, 27, 111, .25);
}
.app-bar__brand { display: flex; align-items: center; gap: .6rem; color: #fff; text-decoration: none; min-width: 0; }
.app-bar__brand img { width: 36px; height: 36px; border-radius: 10px; background: #fff; padding: 2px; object-fit: contain; }
.app-bar__title { font-weight: 700; font-size: 1.02rem; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-bar__subtitle { font-size: .72rem; opacity: .75; display: block; }
.app-bar__actions { margin-left: auto; display: flex; align-items: center; gap: .25rem; }
.icon-btn {
    position: relative; width: 42px; height: 42px; border-radius: 12px;
    display: inline-flex; align-items: center; justify-content: center;
    border: 0; background: transparent; color: inherit; font-size: 1.25rem;
}
.icon-btn:hover, .icon-btn:focus-visible { background: rgba(255, 255, 255, .12); }
.icon-btn .badge-dot {
    position: absolute; top: 6px; right: 5px; min-width: 18px; height: 18px; padding: 0 5px;
    border-radius: 9px; background: var(--agts-red); color: #fff; font-size: .68rem; font-weight: 700;
    display: none; align-items: center; justify-content: center; border: 2px solid var(--agts-navy-2);
}
.icon-btn .badge-dot.show { display: inline-flex; }
.avatar {
    width: 38px; height: 38px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--agts-gold); color: var(--agts-navy); font-weight: 800; font-size: .9rem;
    border: 2px solid rgba(255, 255, 255, .6);
}

.app-main {
    padding: calc(var(--agts-appbar-h) + env(safe-area-inset-top) + 1rem) .9rem calc(var(--agts-tabbar-h) + env(safe-area-inset-bottom) + 1.25rem);
    max-width: 1180px; margin: 0 auto;
}

/* Sidebar (desktop) / off-canvas (phone) share the same menu markup. */
.side-nav { display: flex; flex-direction: column; gap: 2px; padding: .5rem; }
.side-nav__label { font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--agts-muted); padding: .9rem .85rem .35rem; }
.side-nav a {
    display: flex; align-items: center; gap: .8rem; padding: .7rem .85rem;
    border-radius: 12px; color: #334155; text-decoration: none; font-weight: 500;
}
.side-nav a i { font-size: 1.15rem; width: 1.25rem; text-align: center; color: #7a8599; }
.side-nav a:hover { background: rgba(var(--agts-blue-rgb), .06); color: var(--agts-blue); }
.side-nav a:hover i { color: var(--agts-blue); }
.side-nav a.active { background: rgba(var(--agts-blue-rgb), .1); color: var(--agts-blue); font-weight: 700; }
.side-nav a.active i { color: var(--agts-blue); }
.side-nav a .badge { margin-left: auto; }

.app-sidebar { display: none; }
.offcanvas.menu-sheet { width: min(86vw, 320px); border-right: 0; }
.menu-sheet .offcanvas-header { background: linear-gradient(140deg, var(--agts-navy), var(--agts-blue)); color: #fff; padding-top: calc(1rem + env(safe-area-inset-top)); }
.menu-sheet .btn-close { filter: invert(1) grayscale(1) brightness(2); }

/* Bottom tab bar - phones and tablets. */
.tab-bar {
    position: fixed; inset: auto 0 0 0; z-index: 1030;
    height: calc(var(--agts-tabbar-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    display: grid; grid-template-columns: repeat(5, 1fr);
    background: rgba(255, 255, 255, .97); backdrop-filter: blur(10px);
    border-top: 1px solid var(--agts-line);
    box-shadow: 0 -4px 16px rgba(15, 23, 42, .06);
}
.tab-bar a, .tab-bar button {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    color: #7a8599; text-decoration: none; font-size: .68rem; font-weight: 600;
    border: 0; background: transparent; position: relative;
}
.tab-bar i { font-size: 1.3rem; line-height: 1; }
.tab-bar .active { color: var(--agts-blue); }
.tab-bar .active::before {
    content: ""; position: absolute; top: 0; width: 28px; height: 3px; border-radius: 0 0 3px 3px; background: var(--agts-blue);
}

@media (min-width: 992px) {
    .app-bar { left: var(--agts-sidebar-w); padding-left: 1.5rem; padding-right: 1.5rem; }
    .app-bar .menu-toggle, .app-bar__brand--mobile { display: none !important; }
    .app-sidebar {
        display: flex; flex-direction: column;
        position: fixed; inset: 0 auto 0 0; width: var(--agts-sidebar-w); z-index: 1031;
        background: #fff; border-right: 1px solid var(--agts-line);
    }
    .app-sidebar__brand {
        display: flex; align-items: center; gap: .75rem; padding: 1rem 1.1rem;
        height: var(--agts-appbar-h); text-decoration: none; color: var(--agts-ink);
        border-bottom: 1px solid var(--agts-line);
    }
    .app-sidebar__brand img { width: 40px; height: 40px; object-fit: contain; }
    .app-sidebar__brand strong { display: block; font-size: 1rem; }
    .app-sidebar__brand small { color: var(--agts-muted); font-size: .72rem; }
    .app-sidebar .side-nav { overflow-y: auto; flex: 1; padding: .75rem; }
    .app-main { margin-left: var(--agts-sidebar-w); padding: calc(var(--agts-appbar-h) + 1.75rem) 2rem 2.5rem; max-width: none; }
    .app-main > .container-narrow { max-width: 1120px; margin: 0 auto; }
    .tab-bar { display: none; }
}

/* ---------- Page furniture ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-head h1 { font-size: 1.35rem; font-weight: 800; margin: 0; letter-spacing: -.01em; }
.page-head p { margin: .2rem 0 0; color: var(--agts-muted); font-size: .88rem; }
@media (min-width: 768px) { .page-head h1 { font-size: 1.6rem; } }

.card-agts {
    background: var(--agts-card); border: 1px solid var(--agts-line); border-radius: var(--agts-radius);
    box-shadow: var(--agts-shadow);
}
.card-agts > .card-body, .card-agts .card-pad { padding: 1.1rem; }
@media (min-width: 768px) { .card-agts > .card-body, .card-agts .card-pad { padding: 1.4rem; } }
.card-agts .card-title { font-weight: 700; font-size: 1rem; margin-bottom: .2rem; }
.section-title { font-size: .78rem; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; color: var(--agts-muted); margin: 1.4rem 0 .6rem; }

/* Hero - the dashboard greeting and money summary. */
.hero {
    position: relative; overflow: hidden; color: #fff; border-radius: 20px; padding: 1.25rem;
    background: radial-gradient(120% 140% at 100% 0%, var(--agts-blue) 0%, var(--agts-navy) 70%);
    box-shadow: 0 12px 30px rgba(11, 27, 111, .28);
}
.hero::after {
    content: ""; position: absolute; right: -40px; bottom: -60px; width: 220px; height: 220px; border-radius: 50%;
    border: 26px solid rgba(246, 211, 28, .18);
}
.hero__greet { font-size: .85rem; opacity: .85; }
.hero__name { font-size: 1.35rem; font-weight: 800; margin: .1rem 0 .35rem; line-height: 1.2; }
.hero__meta { font-size: .8rem; opacity: .85; display: flex; flex-wrap: wrap; gap: .35rem .9rem; }
.hero__chip { display: inline-flex; align-items: center; gap: .35rem; background: rgba(255, 255, 255, .12); border-radius: 999px; padding: .25rem .65rem; font-size: .75rem; font-weight: 600; }
.hero__money { position: relative; z-index: 1; margin-top: 1.1rem; padding-top: 1rem; border-top: 1px solid rgba(255, 255, 255, .15); display: flex; align-items: flex-end; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
.hero__money small { display: block; font-size: .75rem; opacity: .8; }
.hero__money strong { font-size: 1.6rem; font-weight: 800; letter-spacing: -.02em; }
@media (min-width: 768px) { .hero { padding: 1.75rem; } .hero__name { font-size: 1.7rem; } }

/* Stat tiles */
.stat {
    display: flex; gap: .8rem; align-items: center; padding: 1rem; height: 100%;
    background: #fff; border: 1px solid var(--agts-line); border-radius: var(--agts-radius); box-shadow: var(--agts-shadow);
}
.stat__icon {
    flex-shrink: 0; width: 44px; height: 44px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center;
    font-size: 1.3rem; background: rgba(var(--agts-blue-rgb), .1); color: var(--agts-blue);
}
.stat__icon--gold { background: rgba(246, 211, 28, .25); color: #8a6d00; }
.stat__icon--red { background: rgba(216, 32, 27, .1); color: var(--agts-red); }
.stat__icon--green { background: rgba(22, 163, 74, .12); color: #15803d; }
.stat > div { min-width: 0; }
.stat__label { font-size: .75rem; color: var(--agts-muted); font-weight: 600; }
.stat__value { font-size: 1.15rem; font-weight: 800; line-height: 1.15; }

/* "Needs your attention" list */
.todo { display: flex; align-items: center; gap: .85rem; padding: .9rem 1rem; text-decoration: none; color: inherit; border-top: 1px solid var(--agts-line); }
.todo:first-child { border-top: 0; }
.todo:hover { background: #f8f9fd; color: inherit; }
.todo__icon { flex-shrink: 0; width: 40px; height: 40px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; font-size: 1.15rem; }
.todo__body { flex: 1; min-width: 0; }
.todo__title { font-weight: 700; font-size: .92rem; }
.todo__text { font-size: .8rem; color: var(--agts-muted); }
.todo__go { color: #a3acbd; font-size: 1.1rem; }
.tone-blue { background: rgba(var(--agts-blue-rgb), .1); color: var(--agts-blue); }
.tone-gold { background: rgba(246, 211, 28, .28); color: #7a6100; }
.tone-red { background: rgba(216, 32, 27, .1); color: var(--agts-red); }
.tone-green { background: rgba(22, 163, 74, .12); color: #15803d; }
.tone-slate { background: #eef1f6; color: #475569; }

/* Quick actions grid */
.quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: .6rem; }
.quick a {
    display: flex; flex-direction: column; align-items: center; gap: .4rem; padding: .85rem .3rem;
    background: #fff; border: 1px solid var(--agts-line); border-radius: 14px; text-decoration: none;
    color: #334155; font-size: .72rem; font-weight: 600; text-align: center; line-height: 1.15;
}
.quick a i { font-size: 1.35rem; color: var(--agts-blue); }
.quick a:active { transform: scale(.97); }
@media (min-width: 768px) { .quick { grid-template-columns: repeat(8, 1fr); } }

/* Badges / status pills */
.pill { display: inline-flex; align-items: center; gap: .3rem; padding: .22rem .6rem; border-radius: 999px; font-size: .72rem; font-weight: 700; white-space: nowrap; }
.pill-success { background: #dcfce7; color: #166534; }
.pill-warning { background: #fef3c7; color: #92400e; }
.pill-danger { background: #fee2e2; color: #991b1b; }
.pill-info { background: rgba(var(--agts-blue-rgb), .1); color: var(--agts-blue); }
.pill-muted { background: #eef1f6; color: #475569; }

/* Tables: a normal table from 768px, a stack of cards below it. */
.table-agts { width: 100%; margin: 0; }
.table-agts thead th { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--agts-muted); font-weight: 700; background: #f8f9fd; border-bottom: 1px solid var(--agts-line); padding: .75rem 1rem; white-space: nowrap; }
.table-agts td { padding: .8rem 1rem; border-top: 1px solid var(--agts-line); vertical-align: middle; }
.table-agts tfoot th, .table-agts tfoot td { padding: .8rem 1rem; border-top: 2px solid var(--agts-line); background: #fbfcfe; }
@media (max-width: 767.98px) {
    .table-stack thead { display: none; }
    .table-stack, .table-stack tbody, .table-stack tr, .table-stack td { display: block; width: 100%; }
    .table-stack tr { padding: .8rem 1rem; border-top: 1px solid var(--agts-line); }
    .table-stack tbody tr:first-child { border-top: 0; }
    .table-stack td { border: 0; padding: .18rem 0; display: flex; justify-content: space-between; gap: 1rem; text-align: right; }
    .table-stack td::before { content: attr(data-label); color: var(--agts-muted); font-size: .78rem; font-weight: 600; text-align: left; flex-shrink: 0; }
    .table-stack td[data-label=""]::before { display: none; }
    .table-stack td.td-main { font-weight: 700; font-size: .95rem; text-align: left; justify-content: flex-start; padding-bottom: .35rem; }
    .table-stack td.td-main::before { display: none; }
    .table-stack td.td-actions { justify-content: flex-end; padding-top: .5rem; }
    .table-stack td.td-actions::before { display: none; }
    .table-stack tfoot, .table-stack tfoot tr { display: block; width: 100%; }
    .table-stack tfoot th, .table-stack tfoot td { display: flex; justify-content: space-between; border: 0; }
}

/* Selectable rows (courses, resit papers) - the whole row is the tap target. */
.pick-list { list-style: none; margin: 0; padding: 0; }
.pick {
    display: flex; align-items: center; gap: .85rem; padding: .85rem 1rem; border-top: 1px solid var(--agts-line); cursor: pointer; margin: 0;
}
.pick:first-child { border-top: 0; }
.pick:hover { background: #f8f9fd; }
.pick .form-check-input { width: 1.35rem; height: 1.35rem; margin: 0; flex-shrink: 0; }
.pick__body { flex: 1; min-width: 0; }
.pick__title { font-weight: 700; font-size: .92rem; }
.pick__meta { font-size: .78rem; color: var(--agts-muted); }
.pick__end { font-weight: 800; white-space: nowrap; }
.pick:has(input:checked) { background: rgba(var(--agts-blue-rgb), .05); }

/* Sticky action bar on phones for pages with a primary action. */
.sticky-action {
    position: sticky; bottom: calc(var(--agts-tabbar-h) + env(safe-area-inset-bottom) + .6rem); z-index: 20;
    display: flex; align-items: center; justify-content: space-between; gap: .75rem;
    padding: .75rem .9rem; margin-top: 1rem; border-radius: 16px;
    background: var(--agts-navy); color: #fff; box-shadow: 0 10px 28px rgba(11, 27, 111, .35);
}
.sticky-action small { display: block; opacity: .75; font-size: .72rem; }
.sticky-action strong { font-size: 1.1rem; }
@media (min-width: 992px) { .sticky-action { bottom: 1rem; } }

/* Empty states */
.empty { text-align: center; padding: 2.2rem 1rem; color: var(--agts-muted); }
.empty i { font-size: 2.4rem; color: #c3cad8; display: block; margin-bottom: .6rem; }
.empty strong { display: block; color: var(--agts-ink); font-size: 1rem; margin-bottom: .2rem; }

/* Segmented tabs (Bills / Transactions) */
.seg { display: inline-flex; padding: 4px; background: #e8ebf5; border-radius: 14px; gap: 4px; width: 100%; }
.seg button { flex: 1; border: 0; background: transparent; padding: .55rem 1rem; border-radius: 11px; font-weight: 700; color: #475569; font-size: .88rem; }
.seg button.active { background: #fff; color: var(--agts-blue); box-shadow: 0 1px 4px rgba(15, 23, 42, .1); }
@media (min-width: 576px) { .seg { width: auto; } }

/* Modals as bottom sheets on phones. */
@media (max-width: 575.98px) {
    .modal.sheet .modal-dialog { margin: 0; position: fixed; bottom: 0; left: 0; right: 0; max-width: none; transform: translateY(100%); transition: transform .25s ease-out; }
    .modal.sheet.show .modal-dialog { transform: none; }
    .modal.sheet .modal-content { border-radius: 22px 22px 0 0; padding-bottom: env(safe-area-inset-bottom); max-height: 92vh; }
    .modal.sheet .modal-content::before { content: ""; display: block; width: 42px; height: 5px; border-radius: 3px; background: #d4d9e4; margin: .6rem auto 0; }
    .modal.sheet .modal-body { overflow-y: auto; }
}
.modal-content { border: 0; border-radius: 20px; }
.modal-header { border-bottom: 1px solid var(--agts-line); }
.modal-title { font-weight: 800; }

/* Notifications panel */
.notif-item { padding: .85rem 1rem; border-bottom: 1px solid var(--agts-line); }
.notif-item.unread { background: rgba(var(--agts-blue-rgb), .04); border-left: 3px solid var(--agts-blue); }
.notif-item__title { font-weight: 700; font-size: .9rem; }
.notif-item__text { font-size: .82rem; color: #475569; margin-top: .15rem; }
.notif-item__time { font-size: .72rem; color: var(--agts-muted); margin-top: .3rem; }

/* Flash messages */
.flash { display: flex; gap: .7rem; align-items: flex-start; padding: .85rem 1rem; border-radius: 14px; margin-bottom: 1rem; background: #fff; border: 1px solid var(--agts-line); border-left: 4px solid; box-shadow: var(--agts-shadow); font-weight: 500; }
.flash i { font-size: 1.15rem; line-height: 1.2; }
.flash--success { border-left-color: #16a34a; } .flash--success i { color: #16a34a; }
.flash--warning { border-left-color: #d97706; } .flash--warning i { color: #d97706; }
.flash--danger { border-left-color: var(--agts-red); } .flash--danger i { color: var(--agts-red); }
.flash .btn-close { margin-left: auto; font-size: .7rem; }
.flash ul { margin: 0; padding-left: 1.1rem; }

/* Skeleton loading */
.skeleton { background: linear-gradient(90deg, #eef1f6 25%, #f7f8fb 50%, #eef1f6 75%); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 8px; height: 14px; }
@keyframes sk { to { background-position: -200% 0; } }

/* Money */
.money { font-variant-numeric: tabular-nums; }

/* Print: just the document, no chrome. */
@media print {
    .app-bar, .app-sidebar, .tab-bar, .no-print, .offcanvas, .sticky-action { display: none !important; }
    .app-main { margin: 0 !important; padding: 0 !important; }
    body { background: #fff; }
    .card-agts { box-shadow: none; border: 0; }
    .print-only { display: block !important; }
}
.print-only { display: none; }

/* Motion preference */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}
