/*
 * The panels' own look (ADR-059): Filament's engine, the school's colours.
 *
 * Plain CSS, no build (ADR-006), like admin-a11y.css. Registered on both panels (staff,
 * applicant portal; ADR-063) through PanelTema::pasang, which loads it AFTER the global admin-a11y.css: so this file
 * never sets a control's height, padding or font size. Sizing and hit areas stay there.
 * Unlayered, so it beats Filament's `@layer components` rules. Values come from the public
 * site's tokens (tokens.css, loaded into the panel) and the school's --brand-* colours,
 * printed per request by the panel's head hook; Filament's own --primary-* ramp is generated
 * from the same colours (PanelPalette::forSekolah).
 */

/* --------------------------------------------------------------------------
   Image picker (ADR-058)
   -------------------------------------------------------------------------- */

/* The field: the chosen image, then its buttons. */
.pustaka-field {
    display: grid;
    gap: 0.75rem;
    justify-items: start;
}

.pustaka-field__pratinjau {
    margin: 0;
    max-width: 12rem;
}

.pustaka-field__pratinjau img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: var(--brand-radius, 0.625rem);
    border: 1px solid var(--gray-200);
    background: var(--gray-50);
}

.pustaka-field__nama,
.pustaka-field__kosong,
.pustaka-field__hilang {
    margin: 0;
    font-size: 0.875rem;
    color: var(--gray-600);
    overflow-wrap: anywhere;
}

.pustaka-field__hilang {
    color: var(--danger-700);
}

.pustaka-field__tombol {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

/* The modal: a bottom sheet on a phone (mobile first), centred from tablet up. */
.fi-modal-window-ctn:has(> .pustaka-modal) {
    min-height: 100%;
    display: flex;
    flex-direction: column;
    padding-block-end: 0;
}

.pustaka-modal {
    max-height: 92dvh;
    overflow-y: auto;
    margin-block: auto 0;
    border-end-start-radius: 0;
    border-end-end-radius: 0;
}

@media (min-width: 48rem) {
    .fi-modal-window-ctn:has(> .pustaka-modal) {
        padding-block-end: 1rem;
    }

    .pustaka-modal {
        margin-block: auto;
        border-end-start-radius: var(--brand-radius-lg);
        border-end-end-radius: var(--brand-radius-lg);
    }
}

/* The two tabs share the width, so "Unggah baru" is never scrolled out of sight. */
.pustaka-modal .fi-tabs {
    width: 100%;
}

.pustaka-modal .fi-tabs-item {
    flex: 1 1 0;
    white-space: normal;
    text-align: center;
}

/* The grid: a date heading, then that day's images in one wrapping row. */
.pustaka-pilih {
    display: grid;
    gap: 1.5rem;
}

.pustaka-pilih__tanggal {
    margin: 0 0 0.75rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--gray-700);
}

.pustaka-pilih__daftar {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(7.5rem, 1fr));
    gap: 0.75rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.pustaka-pilih__item {
    display: grid;
    gap: 0.375rem;
    cursor: pointer;
}

/* The input is visually replaced by the thumbnail's ring; it stays focusable and labelled. */
.pustaka-pilih__input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
}

.pustaka-pilih__gambar {
    margin: 0;
    position: relative;
}

.pustaka-pilih__gambar img {
    display: block;
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: var(--brand-radius-sm, 0.375rem);
    border: 2px solid transparent;
    background: var(--gray-100);
}

.pustaka-pilih__input:checked + .pustaka-pilih__gambar img {
    border-color: var(--primary-600);
    box-shadow: 0 0 0 3px var(--primary-200);
}

/* Selection is shown by a tick as well as the colour, never by colour alone. */
.pustaka-pilih__input:checked + .pustaka-pilih__gambar::after {
    content: "\2713";
    position: absolute;
    top: 0.375rem;
    right: 0.375rem;
    display: grid;
    place-items: center;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 50%;
    background: var(--primary-600);
    color: var(--brand-on-primary);
    font-weight: 700;
}

.pustaka-pilih__nama {
    font-size: 0.8125rem;
    color: var(--gray-600);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pustaka-pilih__kosong {
    margin: 0;
    color: var(--gray-600);
}

.pustaka-pilih__lanjut {
    margin: 0;
    text-align: center;
}

/* --------------------------------------------------------------------------
   Page canvas and type: the school's font, surfaces and ink
   -------------------------------------------------------------------------- */
.fi-body {
    font-family: var(--brand-font-body);
}

:where(.fi-header-heading, .fi-section-header-heading, .fi-simple-header-heading) {
    font-family: var(--brand-font-heading);
    letter-spacing: -0.01em;
}

/*
 * Light mode only: the school's surface and ink. Dark mode keeps Filament's own dark
 * surfaces, which its text colours are made for (a light surface under them is unreadable).
 */
html:not(.dark) .fi-body {
    background: var(--brand-surface);
    color: var(--brand-body);
}

html:not(.dark) :where(.fi-header-heading, .fi-section-header-heading, .fi-simple-header-heading) {
    color: var(--brand-ink);
}

/*
 * Primary-coloured TEXT on a light surface (links, badges, outlined buttons, table text).
 *
 * Filament picks the text shade per element at boot, from the platform palette, where 500
 * is dark enough (7.0:1), and writes it as a class (`fi-text-color-500`). The school's ramp
 * then swaps what that shade IS per request, so a bright school colour landed on white at
 * 2.01:1 (smk-nusa's "Lupa kata sandi?", ADR-063). Shade 600 is the one the ramp guarantees
 * at >= 4.5:1 on white (PanelRampTest), so any lighter choice is lifted to it. `--text` is
 * the light-mode variable only; dark mode reads `--dark-text`, untouched.
 *
 * NOT on a filled element (`fi-bg-color-*`): a filled button's text is `fi-text-color-50`
 * ON a 600 background, and lifting it to 600 would make the label vanish.
 */
.fi-color-primary:is(.fi-text-color-50, .fi-text-color-100, .fi-text-color-200, .fi-text-color-300, .fi-text-color-400, .fi-text-color-500):not([class*="fi-bg-color-"]) {
    --text: var(--color-600);
}

/*
 * The same boot-time choice for a filled button's HOVER: shade 500 behind near-white text,
 * fine on the platform palette, about 2:1 on a bright school colour. Hover goes one step
 * DARKER instead (700), which the ramp guarantees too (white on 600 >= 4.5:1, 700 darker).
 */
.fi-color-primary:is(.hover\:fi-bg-color-400, .hover\:fi-bg-color-500) {
    --hover-bg: var(--color-700);
}

.fi-color-primary:is(.dark\:hover\:fi-bg-color-400, .dark\:hover\:fi-bg-color-500) {
    --dark-hover-bg: var(--color-700);
}

/* Text for screen readers only (Filament's build has no such utility). */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* --------------------------------------------------------------------------
   Brand mark (logo + name): shared by the sidebar, the topbar and the sign-in panel.
   The shell itself (sidebar, topbar, page header) lives in admin-shell.css (ADR-075).
   -------------------------------------------------------------------------- */
.tema-merek {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

.tema-merek__logo {
    flex: none;
    width: 2.5rem;
    height: 2.5rem;
    object-fit: contain;
    border-radius: var(--brand-radius-sm);
    background: var(--brand-surface-card);
    padding: 0.125rem;
}

.tema-merek__nama {
    font-weight: 700;
    font-size: 1rem;
    line-height: 1.25;
    overflow-wrap: anywhere;
}


/* --------------------------------------------------------------------------
   Sections and tables: cards from the school's tokens
   -------------------------------------------------------------------------- */
.fi-section:not(.fi-section-not-contained),
.fi-ta-ctn,
.fi-wi-stats-overview-stat {
    border-radius: var(--brand-radius-lg);
    box-shadow: var(--brand-shadow-sm);
}

html:not(.dark) :is(.fi-section:not(.fi-section-not-contained), .fi-ta-ctn, .fi-wi-stats-overview-stat) {
    border: 1px solid var(--brand-border);
}

.fi-section-header-heading {
    font-size: 1.0625rem;
}

html:not(.dark) .fi-ta-header-cell {
    background: var(--brand-primary-50);
    color: var(--brand-ink);
}

html:not(.dark) .fi-ta-row:hover {
    background: var(--brand-primary-50);
}

/* --------------------------------------------------------------------------
   Simple pages (register, reset, verify): the school's colours behind a white card.
   The login pages wear the split layout of masuk.css (ADR-074) instead.
   -------------------------------------------------------------------------- */
.fi-simple-layout:not(:has(.tema-masuk)) {
    background:
        radial-gradient(circle at 20% 10%, color-mix(in srgb, var(--brand-primary-light) 35%, transparent), transparent 45%),
        linear-gradient(160deg, var(--brand-primary-dark), var(--brand-primary));
}

.fi-simple-layout:not(:has(.tema-masuk)) .fi-simple-main {
    border-radius: var(--brand-radius-lg);
    box-shadow: var(--brand-shadow-lg);
}

/* Filament keeps an empty 36px actions box above a table with no header actions. */
.fi-ta-actions:not(:has(*)) {
    display: none;
}

/* Dark mode: the picker's secondary text one step lighter, so it keeps its contrast. */
html.dark :is(.pustaka-field__nama, .pustaka-field__kosong, .pustaka-pilih__nama, .pustaka-pilih__kosong) {
    color: var(--gray-400);
}

html.dark .pustaka-pilih__tanggal {
    color: var(--gray-300);
}

/* --------------------------------------------------------------------------
   Statistics page (ADR-069): one column on a phone, two from md. Each table
   scrolls inside its own box, never the page. The bar is decoration only.
   -------------------------------------------------------------------------- */
.statistik-grid {
    display: grid;
    gap: 1.5rem;
    grid-template-columns: minmax(0, 1fr);
}

@media (min-width: 768px) {
    .statistik-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.statistik-gulir {
    overflow-x: auto;
}

.statistik-tabel {
    width: 100%;
    border-collapse: collapse;
}

.statistik-tabel th,
.statistik-tabel td {
    padding: 0.5rem 0.5rem 0.5rem 0;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid var(--gray-200);
}

.statistik-tabel thead th {
    font-weight: 600;
}

.statistik-tabel tbody th {
    font-weight: 400;
    width: 100%;
}

.statistik-tabel td {
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.statistik-label {
    display: block;
    overflow-wrap: anywhere;
}

.statistik-batang {
    display: block;
    margin-top: 0.25rem;
    height: 0.375rem;
    border-radius: 9999px;
    background: var(--gray-100);
}

.statistik-batang > span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--primary-600);
}

/* A period that cannot be counted (end before start): said in words, in the error colour. */
.statistik-galat {
    color: var(--danger-700);
    font-weight: 600;
}

.dark .statistik-tabel th,
.dark .statistik-tabel td {
    border-bottom-color: var(--gray-700);
}

.dark .statistik-batang {
    background: var(--gray-800);
}
