/*
 * K2 report styles.
 *
 * Moved OUT of the Blade views on purpose.
 *
 * _styles.blade.php emitted a <script> and a <style> INSIDE the Livewire
 * component, and the filter partial emitted a third. Livewire keeps one root
 * element per component and discards the rest when it morphs the DOM — which
 * is why the tab strip, toolbar and table vanished while the filters survived,
 * and why nothing ever appeared in the log: nothing threw.
 *
 * Loaded from theme-assets.blade.php, which sits outside the component.
 */

/* ================= report shell ================= */
/* ---------- shell ---------- */
    .k2rep-card { background: var(--k2-paper-raised, #fff); border: 1px solid var(--k2-rule, #e4e8f1); border-radius: .85rem; overflow: visible; }
    .k2rep-head { padding: .85rem 1.1rem; border-bottom: 1px solid var(--k2-rule, #e4e8f1); display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
    .k2rep-title { font-weight: 650; font-size: 1rem; letter-spacing: -.01em; }
    .k2rep-sub { font-size: .78rem; color: #64748b; }

    /* ---------- report switcher ---------- */
    .k2rep-nav { display: flex; gap: .35rem; overflow-x: auto; padding: .6rem 1.1rem; border-bottom: 1px solid var(--k2-rule, #e4e8f1); scrollbar-width: thin; }
    .k2rep-nav a { display: inline-flex; align-items: center; gap: .4rem; white-space: nowrap; padding: .4rem .7rem; border-radius: .5rem; font-size: .82rem; font-weight: 500; color: #475569; text-decoration: none; border: 1px solid transparent; transition: background-color .15s, color .15s, border-color .15s; }
    .k2rep-nav a:hover { background: #f1f5f9; color: #0f172a; }
    .k2rep-nav a svg { width: 1rem; height: 1rem; opacity: .65; }
    .k2rep-nav a.is-active { background: var(--k2-accent, #e8a33d); border-color: var(--k2-accent, #e8a33d); color: #40260a; font-weight: 650; }
    .k2rep-nav a.is-active svg { opacity: 1; }

    /*
     | Tab BUTTONS, not links.
     |
     | The switcher strip was styled for <a> only, because that is all it
     | originally held. Pages that switch a tab in place use a <button> - it
     | must not navigate - and those were rendering as bare unstyled text, so
     | a working tab looked like a missing one.
     |
     | Same rules as the anchors above, plus the button reset browsers need.
     */
    .k2rep-navlink {
        display: inline-flex; align-items: center; gap: .4rem;
        white-space: nowrap; padding: .4rem .7rem; border-radius: .5rem;
        font-size: .82rem; font-weight: 500; color: #475569;
        background: none; border: 1px solid transparent; cursor: pointer;
        font-family: inherit; line-height: 1.2;
        transition: background-color .15s, color .15s, border-color .15s;
    }

    .k2rep-navlink:hover { background: #f1f5f9; color: #0f172a; }

    .k2rep-navlink.is-on {
        background: var(--k2-accent, #e8a33d);
        border-color: var(--k2-accent, #e8a33d);
        color: #40260a; font-weight: 650;
    }

    .dark .k2rep-navlink { color: #94a3b8; }
    .dark .k2rep-navlink:hover { background: rgba(255,255,255,.05); color: #e6ebf7; }

    /* ---------- filters ---------- */
    .k2rep-bar { display: flex; align-items: flex-end; gap: .7rem; padding: .8rem 1.1rem; flex-wrap: wrap; border-bottom: 1px solid var(--k2-rule, #e4e8f1); }
    .k2rep-field { display: flex; flex-direction: column; gap: .25rem; }
    .k2rep-field label { font-size: .67rem; text-transform: uppercase; letter-spacing: .05em; color: #64748b; font-weight: 650; }
    .k2rep-field label .req { color: #e24b4a; margin-left: .12rem; font-weight: 700; }
    .k2rep-field.is-required select:invalid,
    .k2rep-field.is-required input:invalid { border-color: #fca5a5; }
    .k2rep-req-note { font-size: .7rem; color: #94a3b8; padding: 0 1.1rem .6rem; }
    .k2rep-req-note b { color: #e24b4a; }
    .k2rep-field select, .k2rep-field input { padding: .42rem .6rem; border: 1px solid var(--k2-rule, #e4e8f1); border-radius: .5rem; font-size: .84rem; background: var(--k2-paper-raised, #fff); color: inherit; min-width: 10rem; }
    .k2rep-field input[type="number"] { min-width: 6rem; }
    .k2rep-field.is-wide select { min-width: 17rem; }
    .k2rep-field select:focus, .k2rep-field input:focus { outline: none; box-shadow: 0 0 0 3px var(--k2-accent-soft, rgba(232,163,61,.16)); }

    /* ---------- toolbar ---------- */
    .k2rep-tools { display: flex; align-items: center; gap: .4rem; margin-left: auto; position: relative; }
    .k2rep-btn { display: inline-flex; align-items: center; gap: .35rem; padding: .42rem .7rem; border: 1px solid var(--k2-rule, #e4e8f1); border-radius: .5rem; background: var(--k2-paper-raised, #fff); font-size: .79rem; font-weight: 600; color: #475569; cursor: pointer; white-space: nowrap; transition: background-color .15s, border-color .15s, color .15s; }
    .k2rep-btn:hover { background: #f8fafc; border-color: #cbd5e1; color: #0f172a; }
    .k2rep-btn.has-hidden { border-color: var(--k2-accent, #e8a33d); background: var(--k2-accent-soft, rgba(232,163,61,.16)); color: #8a5a0b; }
    .k2rep-btn svg { width: .95rem; height: .95rem; }
    .k2rep-menu { position: absolute; right: 0; top: calc(100% + .35rem); z-index: 40; min-width: 13rem; max-height: 20rem; overflow-y: auto; padding: .4rem; border: 1px solid var(--k2-rule, #e4e8f1); border-radius: .6rem; background: var(--k2-paper-raised, #fff); box-shadow: 0 12px 32px -10px rgba(16,22,43,.28); display: none; }
    .k2rep-menu.is-open { display: block; }
    .k2rep-menu-head { display: flex; justify-content: space-between; align-items: center; padding: .25rem .45rem .4rem; font-size: .68rem; text-transform: uppercase; letter-spacing: .05em; color: #64748b; font-weight: 650; border-bottom: 1px solid var(--k2-rule,#e4e8f1); margin-bottom: .25rem; }
    .k2rep-menu-head button { border: 0; background: none; color: rgb(var(--primary-600)); font-size: .7rem; font-weight: 600; cursor: pointer; }
    .k2rep-colopt { display: flex; align-items: center; gap: .5rem; padding: .32rem .45rem; border-radius: .4rem; font-size: .82rem; cursor: pointer; }
    .k2rep-colopt:hover { background: #f1f5f9; }
    .k2rep-colopt input { accent-color: var(--k2-accent, #e8a33d); }

    /* ---------- table ---------- */
    .k2rep-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
    .k2rep-table th { position: sticky; top: 0; background: #f8fafc; font-size: .7rem; text-transform: uppercase; letter-spacing: .04em; color: #64748b; text-align: left; padding: .55rem .85rem; border-bottom: 1px solid var(--k2-rule, #e4e8f1); z-index: 2; white-space: nowrap; }
    .k2rep-table td { padding: .45rem .85rem; border-bottom: 1px solid #f1f5f9; }
    .k2rep-table tbody tr:hover { background: #f8fafc; }
    .k2rep-table .num { text-align: right; font-variant-numeric: tabular-nums; }
    .k2rep-scroll { max-height: 60vh; overflow: auto; }

    /* ---------- stats ---------- */
    .k2rep-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .75rem; padding: 1rem 1.1rem; }
    .k2rep-stat { border: 1px solid var(--k2-rule, #e4e8f1); border-radius: .65rem; padding: .7rem .85rem; }
    .k2rep-stat span { display: block; font-size: .67rem; text-transform: uppercase; letter-spacing: .05em; color: #64748b; margin-bottom: .2rem; }
    .k2rep-stat strong { font-size: 1.35rem; font-weight: 700; letter-spacing: -.02em; }

    .k2rep-pill { display: inline-block; font-size: .68rem; font-weight: 650; padding: .12rem .45rem; border-radius: 999px; }
    .p-ok { background: #dcfce7; color: #166534; }
    .p-warn { background: #fef3c7; color: #854f0b; }
    .p-bad { background: #fee2e2; color: #a32d2d; }
    .p-gray { background: #f1f5f9; color: #475569; }

    .k2rep-empty { padding: 2.5rem 1rem; text-align: center; color: #64748b; font-size: .88rem; }
    .k2rep-foot { padding: .7rem 1.1rem; border-top: 1px solid var(--k2-rule, #e4e8f1); font-size: .76rem; color: #64748b; background: #fafbfe; }
    .k2rep-bar-track { height: 6px; border-radius: 999px; background: #f1f5f9; overflow: hidden; min-width: 4.5rem; }
    .k2rep-bar-fill { height: 100%; border-radius: 999px; background: var(--k2-accent, #e8a33d); }

    /* ---------- dark ---------- */
    .dark .k2rep-card { background: #141b31; border-color: rgba(255,255,255,.07); }
    .dark .k2rep-table th, .dark .k2rep-foot { background: #111729; }
    .dark .k2rep-table td { border-bottom-color: rgba(255,255,255,.05); }
    .dark .k2rep-table tbody tr:hover { background: rgba(255,255,255,.03); }
    .dark .k2rep-stat, .dark .k2rep-field select, .dark .k2rep-field input,
    .dark .k2rep-btn, .dark .k2rep-menu { border-color: rgba(255,255,255,.08); background: #141b31; color: #cbd5e1; }
    .dark .k2rep-nav a:hover, .dark .k2rep-colopt:hover { background: rgba(255,255,255,.05); color: #e6ebf7; }
    .dark .k2rep-bar-track { background: rgba(255,255,255,.07); }

    /* ---------- print / save-as-PDF ---------- */
    @media print {
        .fi-sidebar, .fi-topbar, .fi-footer, .k2rep-nav, .k2rep-tools,
        .k2rep-bar, .fi-header-actions, #k2-progress { display: none !important; }
        .fi-main, .fi-main-ctn, .fi-page { padding: 0 !important; margin: 0 !important; background: #fff !important; }
        .k2rep-card { border: 0 !important; box-shadow: none !important; }
        .k2rep-scroll { max-height: none !important; overflow: visible !important; }
        .k2rep-table th { position: static !important; background: #eee !important; }
        .k2rep-table { font-size: 10pt; }
        body { background: #fff !important; }
        @page { margin: 12mm; }
    }

/* ================= filter bar ================= */
.k2fb { display: flex; flex-direction: column; gap: .7rem; padding: .2rem 0 .9rem; }

    .k2fb-row { display: flex; flex-wrap: wrap; gap: .55rem; align-items: flex-end; }

    .k2fb-group {
        display: flex; flex-wrap: wrap; gap: .5rem; align-items: flex-end;
        padding: .55rem .7rem .6rem;
        border: 1px solid var(--k2-rule, #e4e8f1);
        border-radius: .7rem;
        background: linear-gradient(to bottom, #fbfcfe, #fff);
        position: relative;
    }

    .k2fb-group > legend,
    .k2fb-legend {
        position: absolute; top: -.55rem; left: .6rem;
        font-size: .62rem; font-weight: 750; letter-spacing: .06em;
        text-transform: uppercase; color: #94a3b8;
        background: #fff; padding: 0 .35rem; border-radius: .3rem;
    }

    .k2fb-field { display: flex; flex-direction: column; gap: .2rem; min-width: 8.5rem; }

    .k2fb-field > label {
        font-size: .68rem; font-weight: 650; color: #64748b; letter-spacing: .01em;
    }

    .k2fb-field select,
    .k2fb-field input {
        height: 2.1rem; padding: 0 .55rem;
        border: 1px solid var(--k2-rule, #dbe2ee); border-radius: .45rem;
        background: #fff; font-size: .82rem; color: #0f172a;
        min-width: 8.5rem;
    }

    .k2fb-field select:focus,
    .k2fb-field input:focus {
        outline: none;
        border-color: var(--k2-accent, #e8a33d);
        box-shadow: 0 0 0 3px rgba(232, 163, 61, .16);
    }

    /* Anything narrowing the result gets an accent edge, so an active filter
       is obvious without reading every box. */
    .k2fb-field.is-on select,
    .k2fb-field.is-on input {
        border-color: var(--k2-accent, #e8a33d);
        background: #fffaf1;
        font-weight: 600;
    }

    .k2fb-reset {
        height: 2.1rem; padding: 0 .8rem;
        border: 1px solid var(--k2-rule, #dbe2ee); border-radius: .45rem;
        background: #fff; font-size: .8rem; font-weight: 600; color: #475569;
        cursor: pointer;
    }

    .k2fb-reset:hover { background: #f1f5f9; }

    .k2fb-chips { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }

    .k2fb-chip {
        display: inline-flex; align-items: center; gap: .3rem;
        font-size: .72rem; font-weight: 600;
        padding: .18rem .55rem; border-radius: 999px;
        background: #fff4e2; color: #8a5a12; border: 1px solid #f2d6a8;
    }

    .k2fb-chip small { font-weight: 500; opacity: .75; }

    .k2fb-none { font-size: .74rem; color: #94a3b8; }

    .dark .k2fb-group { background: rgba(255,255,255,.02); border-color: rgba(255,255,255,.08); }
    .dark .k2fb-legend { background: #141b31; color: #7c8aa5; }
    .dark .k2fb-field select, .dark .k2fb-field input {
        background: #141b31; border-color: rgba(255,255,255,.1); color: #e2e8f0;
    }
    .dark .k2fb-reset { background: #141b31; border-color: rgba(255,255,255,.1); color: #cbd5e1; }

/* ================= readability ================= */

/* ---------- readability ---------- */
.k2rep-table tbody tr:nth-child(even) { background: #fafbfd; }
.k2rep-table tbody tr:hover { background: #fff6e8; }
.k2rep-scroll { max-height: 68vh; overflow: auto; }
.k2rep-table thead th {
    position: sticky; top: 0; z-index: 2; background: #f1f5f9;
    font-size: .68rem; font-weight: 800; letter-spacing: .04em;
    text-transform: uppercase; color: #55637a; white-space: nowrap;
    border-bottom: 2px solid #dbe3ee; padding: .55rem .6rem;
}
.k2rep-table td {
    padding: .5rem .6rem; font-size: .82rem; color: #1e293b;
    border-bottom: 1px solid #eef2f7; vertical-align: middle;
}
.k2rep-table td.num, .k2rep-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.k2rep-table td:first-child { white-space: nowrap; }
.k2rep-table td strong { font-weight: 650; color: #0f172a; }
.k2rep-table tbody tr.k2rep-total td {
    background: #eef2f7; font-weight: 700; border-top: 2px solid #cbd5e1;
}
.k2rep-clickable { cursor: pointer; }
.k2rep-clickable:hover { background: #fff1da !important; }

/* ---------- drill-down panel ---------- */
.k2dr-overlay {
    border: 1px solid #e8a33d; border-radius: .8rem; background: #fff;
    box-shadow: 0 10px 30px rgba(16,22,43,.12); overflow: hidden;
}
.k2dr-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: .75rem; padding: .7rem 1rem; background: #fff8ec;
    border-bottom: 1px solid #e4e8f1;
}
.k2dr-title { font-size: .95rem; font-weight: 700; color: #0f172a; }
.k2dr-sub { font-size: .74rem; color: #94a3b8; }
.k2dr-close {
    border: 1px solid #dbe2ee; border-radius: .45rem; background: #fff;
    padding: .3rem .7rem; cursor: pointer; font-size: .78rem;
    font-weight: 600; color: #475569;
}



/* ================= reports hub =================
 * Moved out of hub.blade.php: a <style> inside a Livewire component is an
 * extra root element, and Livewire keeps only one.
 */

/* ================= reports hub =================
 * The card grid for every reports hub page.
 *
 * These rules were here already but unreachable: the section above them ended
 * mid-Blade, so the parser discarded everything that followed. That is the
 * whole reason the OMR hub showed a stacked list while other hubs - which
 * carry their own copy inline - looked right.
 */
.k2hub-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: .85rem; padding: 1.1rem; }
.k2hub-card { display: flex; gap: .85rem; padding: 1rem; border: 1px solid var(--k2-rule, #e4e8f1); border-radius: .75rem; text-decoration: none; color: inherit; background: var(--k2-paper-raised, #fff); transition: border-color .18s, box-shadow .18s, transform .18s; }
.k2hub-card:hover { border-color: var(--k2-accent, #e8a33d); box-shadow: 0 8px 22px -10px rgba(16,22,43,.25); transform: translateY(-2px); }
.k2hub-icon { flex: none; display: grid; place-items: center; width: 2.5rem; height: 2.5rem; border-radius: .6rem; background: var(--k2-accent-soft, rgba(232,163,61,.16)); color: #b06f10; }
.k2hub-icon svg { width: 1.25rem; height: 1.25rem; }
.k2hub-body h3 { font-size: .93rem; font-weight: 650; letter-spacing: -.01em; margin: 0 0 .2rem; }
.k2hub-body p { font-size: .79rem; color: #64748b; margin: 0; line-height: 1.4; }
.k2hub-card.is-off { opacity: .45; pointer-events: none; }
.dark .k2hub-card { background: #141b31; border-color: rgba(255,255,255,.07); }
.dark .k2hub-icon { color: var(--k2-accent, #e8a33d); }

/* ================= tick boxes =================
 * Filament sets appearance:none on checkboxes and draws its own tick. Inside
 * these report cards that drawing never happens, so a ticked box looked
 * exactly like an empty one - subjects chosen with no way to see which.
 * Handing the box back to the browser brings the native tick back, and
 * accent-color paints it in the school's colour.
 *
 * The rule above sizes every input in a filter field as a 10rem bordered
 * control, which is right for the selects it was written for and turned every
 * checkbox into a wide rounded pill. Scoped overrides rather than narrowing
 * that rule.
 */
.k2rep-field input[type="checkbox"],
.k2rep-field input[type="radio"],
.k2rep-colopt input[type="checkbox"],
.k2rep-colopt input[type="radio"] {
    appearance: auto;
    -webkit-appearance: checkbox;
    min-width: 0; width: 1rem; height: 1rem; flex: none;
    padding: 0; border: 0; border-radius: 0; background: none;
    accent-color: var(--k2-accent, #e8a33d); cursor: pointer;
}

.k2rep-field input[type="radio"], .k2rep-colopt input[type="radio"] { -webkit-appearance: radio; }

/* A ticked option reads differently from an unticked one at a glance. */
.k2rep-colopt:has(input:checked) { background: var(--k2-accent-soft, rgba(232,163,61,.16)); font-weight: 600; }

/* A field holding tick boxes must not stretch them like a text input. */
.k2rep-field.is-checks { min-width: 0; }
.k2rep-checkgrid { display: flex; flex-wrap: wrap; gap: .2rem .9rem; padding: .2rem 0; }
.k2rep-checkgrid .k2rep-colopt { min-width: 9rem; }


/* ================= side drawer =================
 * A panel that slides in from the right instead of a form unrolling below the
 * table. The table stays where it was, so you can see which row you are
 * writing about - which is the whole reason a drawer beats an inline form
 * here.
 */
.k2drawer-veil {
    position: fixed; inset: 0; z-index: 40;
    background: rgba(16, 22, 43, .35);
    backdrop-filter: blur(1px);
}

.k2drawer {
    position: fixed; top: 0; right: 0; bottom: 0; z-index: 41;
    width: min(38rem, 100vw);
    display: flex; flex-direction: column;
    background: var(--k2-paper-raised, #fff);
    border-left: 1px solid var(--k2-rule, #e4e8f1);
    box-shadow: -18px 0 40px -24px rgba(16, 22, 43, .45);
    animation: k2drawer-in .22s ease-out both;
}

@keyframes k2drawer-in {
    from { transform: translateX(100%); }
    to   { transform: translateX(0); }
}

.k2drawer-head {
    flex: none; display: flex; align-items: center; justify-content: space-between;
    gap: .75rem; padding: .9rem 1.1rem;
    border-bottom: 1px solid var(--k2-rule, #e4e8f1);
}

.k2drawer-title { font-size: 1rem; font-weight: 650; letter-spacing: -.01em; }
.k2drawer-sub { font-size: .78rem; color: #64748b; }

/* The only scrolling part, so the heading and the save bar stay put. */
.k2drawer-body { flex: 1; overflow-y: auto; padding: .2rem 0 1rem; }

.k2drawer-foot {
    flex: none; display: flex; gap: .5rem; align-items: center;
    padding: .75rem 1.1rem; border-top: 1px solid var(--k2-rule, #e4e8f1);
    background: #fafbfe;
}

.k2drawer .k2rep-field { width: 100%; }
.k2drawer .k2rep-field select,
.k2drawer .k2rep-field input,
.k2drawer .k2rep-field textarea { width: 100%; min-width: 0; }

.k2drawer-grid { display: grid; gap: .7rem; padding: .9rem 1.1rem; }
.k2drawer-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.k2drawer-row {
    display: flex; justify-content: space-between; align-items: center; gap: .75rem;
    padding: .55rem 1.1rem; border-bottom: 1px solid #f1f5f9; font-size: .85rem;
}

.k2drawer-row:hover { background: #f8fafc; }

.dark .k2drawer { background: #141b31; border-color: rgba(255,255,255,.07); }
.dark .k2drawer-foot { background: #111729; }
.dark .k2drawer-row:hover { background: rgba(255,255,255,.03); }

@media (max-width: 640px) {
    .k2drawer { width: 100vw; }
    .k2drawer-grid.two { grid-template-columns: 1fr; }
}
