:root {
  /* Theme colours, replaced per school in System Settings (includes/branding.php). */
  /* Fallbacks only: layout.php prints the saved theme after this stylesheet. */
  --brand: #800020; --brand-hover: #6B0F1A; --brand-mid: #73001D;
  --brand-dark: #5C0016; --brand-accent: #9C1C3C; --brand-soft: #EFC9D2;
  --ink: #3D0010; --brand-ring: rgba(128,0,32,.12);
}

/* ============================================================
   Documate — Global Stylesheet
   ============================================================ */

/* -- Base resets ------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; }
/* Tailwind's text/spacing utilities are rem-based, so nudging the root size
   scales the whole UI together instead of cramming bigger text into fixed boxes. */
html { font-size: 17px; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; }
a { text-decoration: none; }
button { cursor: pointer; border: none; background: none; font: inherit; }
input, select, textarea { font: inherit; }

/* -- Student page shell ----------------------------------- */
.student-page-shell {
    width: 100%;
    max-width: 80rem;
    min-height: 100%;
    margin: 0 auto;
    padding: 0 clamp(1rem, 4vw, 3rem);
}

@media (max-width: 640px) {
    .student-page-shell { padding: 0 .75rem; }
}

/* -- Brand logo -------------------------------------------- */
/* The school seal is a fine-lined navy/gold crest, so it is set on a light
   disc with a gold ring — that keeps it legible on the maroon sidebar and
   login panel as well as on cream backgrounds. */
.brand-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border-radius: 50%;
    background: #FFFDF9;
    box-shadow: 0 0 0 2px #F5C6A0, 0 2px 8px rgba(61, 0, 16, .22);
}
.brand-logo img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
}
.brand-logo-sm { width: 2.25rem; height: 2.25rem; padding: 3px; }
.brand-logo-md { width: 3rem;    height: 3rem;    padding: 4px; }
.brand-logo-lg { width: 4.5rem;  height: 4.5rem;  padding: 6px; }
/* Sized to match the two-line brand text beside it in the sidebar */
.brand-logo-fit { width: 2.75rem; height: 2.75rem; padding: 3px; }

/* -- Search + category filter bar -------------------------- */
/* Shared by the tracker and confirmation-slip lists. */
.filter-bar { padding: 0 .25rem .75rem; border-bottom: 1px solid #F0E2CB; margin-bottom: .65rem; }
.filter-search-wrap { position: relative; display: flex; align-items: center; }
.filter-search-wrap svg { position: absolute; left: .6rem; pointer-events: none; }
.filter-search { width: 100%; padding: .45rem .6rem .45rem 1.85rem; font-size: .78rem; color: var(--ink); background: #FFF8F0; border: 1px solid #E8D5B7; border-radius: .55rem; }
.filter-search:focus { outline: none; border-color: var(--brand); background: #FFFFFF; }
.filter-search::placeholder { color: #B9A08A; }
.filter-pills { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .5rem; }
.filter-sort-group { display: flex; flex: 0 0 auto; gap: .3rem; }
.filter-sort-btn { flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; gap: .35rem; height: 2.1rem; padding: 0 .65rem; font-size: .75rem; font-weight: 600; color: var(--brand); background: #FFFFFF; border: 1px solid #E8D5B7; border-radius: .55rem; white-space: nowrap; cursor: pointer; transition: background .15s, color .15s, border-color .15s; }
.filter-sort-btn:hover { background: #FFF8F0; border-color: #C4A882; }
.filter-sort-btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.filter-sort-btn svg { flex-shrink: 0; }

/* Square "closest to done" button; filled while that order is on. */
.filter-sort-icon { width: 2.1rem; padding: 0; }
.filter-sort-icon.is-active { background: var(--brand); border-color: var(--brand); color: #FFF8F0; }
.filter-sort-icon.is-active:hover { background: #6B001B; border-color: #6B001B; }

/* ── Student list filter: search, plus sort buttons on the tracker ── */
.pf { padding: 0 .25rem .6rem; border-bottom: 1px solid #F0E2CB; margin-bottom: .65rem; }
.pf-top { display: flex; align-items: center; gap: .4rem; }
.pf-search { position: relative; flex: 1 1 auto; min-width: 0; display: flex; align-items: center; }
.pf-search svg { position: absolute; left: .6rem; pointer-events: none; }

.filter-pill { display: inline-flex; align-items: center; gap: .3rem; padding: .25rem .5rem; font-size: .7rem; font-weight: 600; color: var(--brand); background: #FFFFFF; border: 1px solid #E8D5B7; border-radius: 999px; cursor: pointer; transition: background .15s, color .15s, border-color .15s; }
.filter-pill:hover { border-color: #C4A882; }
.filter-pill.is-active { color: #FFF8F0; background: var(--brand); border-color: var(--brand); }
.filter-pill-count { padding: 0 .3rem; font-size: .65rem; font-weight: 700; border-radius: 999px; background: #F5E6CC; color: var(--brand); }
.filter-pill.is-active .filter-pill-count { background: rgba(255,248,240,.25); color: #FFF8F0; }
.filter-no-match { padding: 1.5rem .5rem; font-size: .8rem; text-align: center; color: #9B7A82; }
.filter-no-match.hidden { display: none; }

/* -- Focus ring -------------------------------------------- */
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* -- Sidebar transition ------------------------------------ */
#sidebar { transition: transform .3s ease; }

/* -- Scrollbar (webkit) ------------------------------------ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #E8D5B7; border-radius: 3px; }

/* -- Card hover shadow ------------------------------------- */
.card-hover { transition: transform .15s, box-shadow .15s; }
.card-hover:hover { transform: translateY(-2px); box-shadow: 0 4px 16px rgba(128,0,32,.1); }

/* -- Table row hover --------------------------------------- */
.tr-hover:hover { background: #FFFAF5; }

/* -- Stepper line ------------------------------------------ */
.step-line { height: 2px; flex: 1; margin: 0 8px 16px; transition: background .3s; }

/* -- Modal overlay ----------------------------------------- */
.modal-overlay {
    position: fixed; inset: 0; z-index: 50;
    display: flex; align-items: center; justify-content: center;
    padding: 1rem; background: rgba(0,0,0,.5);
}
.modal-overlay.hidden { display: none; }
.modal-box {
    background: #fff; border-radius: 1rem; padding: 1.5rem;
    max-width: 420px; width: 100%; box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.help-modal-box { width: min(560px, calc(100vw - 2rem)); max-width: calc(100vw - 2rem); }

/* Roomier modal: pinned header and footer, only the body scrolls, so a long
   form never runs off the bottom of the screen. */
.modal-box-lg {
    max-width: 580px; width: 100%;
    max-height: min(86vh, 760px);
    padding: 0; display: flex; flex-direction: column; overflow: hidden;
}
.modal-head {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    padding: 1.1rem 1.35rem; border-bottom: 1px solid #E8D5B7; flex-shrink: 0;
}
.modal-body { padding: 1.35rem; overflow-y: auto; flex: 1; min-height: 0; }
.modal-foot {
    display: flex; gap: .75rem; padding: 1rem 1.35rem;
    border-top: 1px solid #E8D5B7; background: #FFF8F0; flex-shrink: 0;
}
.modal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .85rem 1rem; }
.modal-grid .col-full { grid-column: 1 / -1; }
.modal-label { display: block; font-size: .8125rem; font-weight: 500; color: var(--ink); margin-bottom: .35rem; }
.modal-label span { color: #9B7A82; font-weight: 400; }
@media (max-width: 600px) {
    .modal-grid { grid-template-columns: 1fr; }
    .modal-box-lg { max-height: 92vh; }
}

/* -- Uploaded file viewer --------------------------------- */
.file-viewer-overlay {
    position: fixed; inset: 0; z-index: 60;
    display: flex; align-items: center; justify-content: center;
    padding: 4.5rem 1.5rem 5.5rem;
    background: rgba(0, 0, 0, .82);
}
.file-viewer-overlay.hidden { display: none; }
.file-viewer-content {
    display: flex; align-items: center; justify-content: center;
    width: 100%; height: 100%; min-height: 0;
}
.file-viewer-content img {
    display: block; max-width: 100%; max-height: 100%;
    object-fit: contain; border-radius: .5rem;
    box-shadow: 0 18px 50px rgba(0, 0, 0, .35);
}
.file-viewer-close,
.file-viewer-download {
    position: fixed; z-index: 1;
    color: #fff; background: rgba(255, 255, 255, .16);
    border: 1px solid rgba(255, 255, 255, .34);
    box-shadow: 0 8px 24px rgba(0, 0, 0, .2);
    transition: background .15s, transform .15s;
}
.file-viewer-close {
    top: 1.25rem; right: 1.25rem;
    display: inline-flex; align-items: center; justify-content: center;
    width: 2.75rem; height: 2.75rem; border-radius: 999px;
}
.file-viewer-download {
    right: 1.5rem; bottom: 1.5rem;
    padding: .7rem 1rem; border-radius: .65rem;
    font-size: .875rem; font-weight: 600;
}
.file-viewer-close:hover,
.file-viewer-download:hover { background: rgba(255, 255, 255, .28); transform: translateY(-1px); }

@media (max-width: 640px) {
    .file-viewer-overlay { padding: 4.5rem 1rem 5.25rem; }
    .file-viewer-close { top: 1rem; right: 1rem; }
    .file-viewer-download { right: 1rem; bottom: 1rem; }
}

/* -- Badge ------------------------------------------------- */
.badge {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 3px 10px; border-radius: 999px;
    font-size: .75rem; font-weight: 500;
}

/* -- Form controls ----------------------------------------- */
.form-input {
    width: 100%; padding: .625rem .75rem; border-radius: .75rem;
    border: 1px solid #E8D5B7; background: #FFFAF5; color: var(--ink);
    font-size: .875rem;
}
.form-input:focus { outline: 2px solid var(--brand); border-color: var(--brand); }
select {
    appearance: none;
    cursor: pointer;
    padding-right: 2.75rem;
    border-color: #D8BFA3;
    background-color: #FFFCF8 !important;
    background-image: linear-gradient(45deg, transparent 50%, var(--brand) 50%), linear-gradient(135deg, var(--brand) 50%, transparent 50%) !important;
    background-position: calc(100% - 1.15rem) 50%, calc(100% - .8rem) 50% !important;
    background-size: .4rem .4rem, .4rem .4rem !important;
    background-repeat: no-repeat !important;
    transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
}
select:hover { border-color: #B88D6D; background-color: #FFF8F0 !important; }
select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); background-color: #FFFFFF !important; }
select option { color: var(--ink); background: #FFFFFF; }
.help-message-input { display: block; min-width: 0; max-width: 100%; resize: vertical; }
.help-modal-content .form-input { width: 100%; max-width: 100%; }
.help-modal-content .form-input:focus { outline: none; box-shadow: 0 0 0 2px var(--brand); }
.help-request-card { transition: background-color .15s, box-shadow .15s; }
.help-request-card.is-focused { background: #FFF8F0; box-shadow: inset 3px 0 0 var(--brand); }

/* -- Buttons ----------------------------------------------- */
.btn-primary {
    display: inline-flex; align-items: center; gap: .5rem;
    padding: .625rem 1.25rem; border-radius: .75rem;
    background: var(--brand); color: #FFF8F0;
    font-size: .875rem; font-weight: 600;
    transition: opacity .15s, transform .1s;
}
.btn-primary:hover { background: var(--brand-hover); color: #FFF8F0; }
.btn-primary:active { transform: scale(.97); }

.btn-outline {
    display: inline-flex; align-items: center; gap: .5rem;
    padding: .625rem 1.25rem; border-radius: .75rem;
    border: 1px solid #E8D5B7; color: var(--brand);
    font-size: .875rem; font-weight: 600;
    transition: background .15s;
}
.btn-outline:hover { background: #F5E6CC; }

.tab-button {
    display: block;
    width: 100%;
    text-align: left;
    padding: .85rem 1rem;
    border-radius: 1rem;
    border: 1px solid transparent;
    font-size: .95rem;
    font-weight: 600;
    transition: background .15s, color .15s, border-color .15s;
}
.tab-button:hover {
    background: #F5E6CC;
}
.tab-button-active:hover {
    background: var(--brand-hover);
    color: #FFF8F0;
}
.tab-button-active {
    background: var(--brand);
    color: #FFF8F0;
    border-color: var(--brand);
}
.tab-button-inactive {
    background: transparent;
    color: #7A5C62;
}

.btn-danger {
    display: inline-flex; align-items: center; gap: .5rem;
    padding: .625rem 1.25rem; border-radius: .75rem;
    background: #EF4444; color: #fff;
    font-size: .875rem; font-weight: 600;
}
.btn-success {
    display: inline-flex; align-items: center; gap: .5rem;
    padding: .625rem 1.25rem; border-radius: .75rem;
    background: #065F46; color: #fff;
    font-size: .875rem; font-weight: 600;
}

/* -- Progress bar ------------------------------------------ */
/* flex-shrink:0 — inside fixed-height cards the bar would otherwise be the
   one element flex collapses to 0 when the text grows */
.progress-bar { height: 6px; flex-shrink: 0; border-radius: 999px; overflow: hidden; background: #F5E6CC; }
.progress-fill { height: 100%; border-radius: 999px; transition: width .3s; }

/* -- Print helper ------------------------------------------ */
@media print {
    aside, header, .no-print { display: none !important; }
    main { padding: 0 !important; }
}

/* -- Responsive table overflow ----------------------------- */
.table-wrap { overflow-x: auto; scrollbar-width: thin; scrollbar-color: #D4AF8F #FFF8F0; }
.table-wrap::-webkit-scrollbar { width: 8px; height: 8px; }
.table-wrap::-webkit-scrollbar-track { background: #FFF8F0; }
.table-wrap::-webkit-scrollbar-thumb { background: #D4AF8F; border-radius: 4px; }
.table-wrap::-webkit-scrollbar-thumb:hover { background: #B8956A; }

/* -- Compact layout (user setting) ------------------------- */
body.documate-compact main {
    padding: 1rem 1.25rem !important;
}
body.documate-compact .rounded-2xl.p-5,
body.documate-compact .rounded-2xl.p-6 {
    padding: 1rem !important;
}
body.documate-compact .mb-6 {
    margin-bottom: 1rem !important;
}
body.documate-compact .space-y-4 > * + * {
    margin-top: 0.75rem !important;
}


/* -- Uploaded file names ----------------------------------- */
/* Phone cameras produce names like
   "IMG_20260913_143022_transcript_scan_final.jpeg" with no spaces to break on,
   so they need an explicit break rule or they run straight out of their box. */
.filename-text {
    min-width: 0;
    overflow-wrap: anywhere;
    word-break: break-word;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* -- Request detail panel -------------------------------- */
/* Shared by the Registrar and Accountant request pages so the two
   read identically. */
/* ---- Request detail panel ---- */
.rd-card {
  display:flex; flex-direction:column; height:100%; overflow:hidden;
  background:#FFFFFF; border:1px solid #E8D5B7; border-radius:1rem;
}
.rd-head {
  display:flex; align-items:flex-start; justify-content:space-between; gap:.75rem;
  flex-shrink:0; padding:.95rem 1.15rem .85rem; background:#FFF8F0;
}
.rd-head-text { min-width:0; }
.rd-student { margin:0; font-size:.95rem; font-weight:700; color:var(--ink); overflow-wrap:anywhere; }
.rd-ref { margin:.1rem 0 0; font-size:.7rem; font-family:ui-monospace,SFMono-Regular,Menlo,monospace; color:#9B7A82; }
.rd-close {
  display:inline-flex; align-items:center; justify-content:center; flex-shrink:0;
  width:1.9rem; height:1.9rem; border-radius:.5rem; color:#9B7A82;
}
.rd-close:hover { background:#F5E6CC; color:var(--brand); }

/* The status led the old list as plain text; here it is a band you cannot miss. */
.rd-statusbar {
  display:flex; align-items:center; gap:.45rem; flex-shrink:0;
  padding:.5rem 1.15rem; font-size:.75rem; font-weight:700;
  border-top:1px solid #E8D5B7; border-bottom:1px solid #E8D5B7;
}
.rd-dot { width:7px; height:7px; border-radius:999px; flex-shrink:0; }

/* Sits under the status band when the student has asked for this document before. */
.rd-repeat {
  display:flex; align-items:flex-start; gap:.45rem; flex-shrink:0;
  padding:.5rem 1.15rem; font-size:.72rem; line-height:1.35;
  background:#FEF3C7; color:#92400E; border-bottom:1px solid #F5E0A3;
}

.rd-body { flex:1 1 auto; min-height:0; overflow-y:auto; padding:.35rem 1.15rem 1rem; }
.rd-group { padding:.85rem 0; }
.rd-group:first-child { padding-top:.5rem; }
.rd-group:last-child { padding-bottom:0; }
.rd-group + .rd-group { border-top:1px solid #F5E6CC; }
.rd-group-card + .rd-group-card { border-top:0; padding-top:.6rem; }
.rd-group-title {
  margin:0 0 .4rem; font-size:.63rem; font-weight:700;
  letter-spacing:.06em; text-transform:uppercase; color:#9B7A82;
}
.rd-row {
  display:flex; align-items:baseline; justify-content:space-between; gap:1rem;
  padding:.2rem 0; font-size:.78rem;
}
.rd-label { color:#7A5C62; flex-shrink:0; }
.rd-value { color:var(--ink); font-weight:600; text-align:right; overflow-wrap:anywhere; }

.rd-chip { padding:.1rem .45rem; border-radius:.35rem; font-size:.68rem; font-weight:700; }
.rd-chip-ok { background:#D1FAE5; color:#065F46; }
.rd-chip-wait { background:#FEF3C7; color:#92400E; }

.rd-file {
  display:flex; align-items:center; gap:.65rem; width:100%; text-align:left;
  padding:.6rem .7rem; border:1px solid #E8D5B7; border-radius:.7rem;
  background:#FFF8F0; color:var(--brand); transition:border-color .12s ease, background .12s ease;
}
.rd-file:hover { border-color:#D4AF8F; background:#FFFDFA; }
.rd-thumb { width:2.4rem; height:2.4rem; border-radius:.45rem; object-fit:cover; flex-shrink:0; }
.rd-fileicon {
  display:inline-flex; align-items:center; justify-content:center; flex-shrink:0;
  width:2.4rem; height:2.4rem; border-radius:.45rem; background:#F5E6CC; color:var(--brand);
}
.rd-file-text { display:flex; flex-direction:column; min-width:0; flex:1 1 auto; }
.rd-file-name {
  font-size:.76rem; font-weight:600; color:var(--ink);
  overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
}
.rd-file-hint { font-size:.66rem; color:#9B7A82; }

.rd-note {
  margin:0; padding:.6rem .7rem; border:1px solid #E8D5B7; border-radius:.7rem;
  background:#FFF8F0; font-size:.76rem; line-height:1.5; color:var(--ink); overflow-wrap:anywhere;
}
.rd-none { margin:0; font-size:.74rem; color:#9B7A82; font-style:italic; }

.rd-foot { flex-shrink:0; padding:.85rem 1.15rem 1rem; border-top:1px solid #E8D5B7; background:#FFFDFA; }
.rd-foot-title {
  margin:0 0 .55rem; font-size:.63rem; font-weight:700;
  letter-spacing:.06em; text-transform:uppercase; color:#9B7A82;
}
.rd-actions { display:flex; flex-direction:column; gap:.5rem; }
.rd-actions > * { width:100%; }
.rd-danger {
  display:inline-flex; align-items:center; gap:.5rem;
  padding:.625rem 1.25rem; border-radius:.75rem;
  border:1px solid #FCA5A5; background:#FFFFFF; color:#9F1239;
  font-size:.875rem; font-weight:600;
}
.rd-danger:hover { background:#FEE2E2; }
.rd-banner {
  width:100%; margin:0; padding:.6rem .7rem; border-radius:.7rem;
  font-size:.74rem; line-height:1.45;
}
.rd-banner-warn { background:#FEF3C7; color:#92400E; }
.rd-banner-ok { background:#D1FAE5; color:#065F46; }

/* -- List toolbar ------------------------------------------ */
/* Shared by both Document Requests pages and the Certificate Desk, so the
   filter row looks the same on every page that has one. */
.request-toolbar { display:flex; flex-wrap:wrap; align-items:center; gap:.5rem; }
.request-toolbar-group { display:flex; align-items:center; gap:.4rem; }
.request-toolbar-label { font-size:.72rem; font-weight:600; color:#7A5C62; }
.request-toolbar-select {
  min-width:12.5rem; padding:.4rem 1.9rem .4rem .7rem;
  border:1px solid #E8D5B7; border-radius:.6rem; background:#FFFFFF;
  font-size:.78rem; font-weight:600; color:var(--brand); cursor:pointer;
}
.request-toolbar-select:focus-visible { outline:2px solid var(--brand); outline-offset:1px; }
.request-toolbar-btn { padding:.375rem .75rem; flex-shrink:0; }
.request-toolbar-chip {
  display:inline-flex; align-items:center; gap:.35rem; flex-shrink:0;
  padding:.35rem .6rem; border:1px solid #E8D5B7; border-radius:.6rem;
  background:#FFF8F0; font-size:.72rem; color:#7A5C62;
}
.request-toolbar-chip strong { color:var(--ink); }
.request-toolbar-chip-x { color:var(--brand); font-size:.95rem; line-height:1; }
.request-toolbar-search { position:relative; flex:0 1 17rem; min-width:12rem; }
.request-toolbar-search svg { position:absolute; left:.7rem; top:50%; transform:translateY(-50%); pointer-events:none; }
.request-toolbar-search-input.form-input { width:100%; padding:.45rem .7rem .45rem 2rem; border-radius:.6rem; font-size:.78rem; }
.request-toolbar-spacer { flex:1 1 auto; }
@media (max-width:720px) { .request-toolbar-spacer { display:none; } }

/* -- Sort buttons ------------------------------------------ */
/* "Newest first" and "Oldest first" share one grid cell, so the button keeps
   the width of the longer label and nothing beside it shifts when it flips. */
.sort-label { display: inline-grid; }
.sort-label > span { grid-area: 1 / 1; }
.sort-label > span + span { visibility: hidden; }
