/* SinghaSport — component styles (plain CSS; works with the Tailwind CDN).
   Palette: slate neutrals + emerald brand + sky accent. No purple / orange. */

:root {
    --brand:       #c39f5c;
    --brand-dark:  #184a2e;
    --brand-light: #eef5ef;
    --ring:        #d3b276;
    --gold:        #d3b276;
    --gold-dark:   #c39f5c;
    --ink:         #12331f;
}

html { scroll-behavior: smooth; }

/* Warm taupe/sand page background — diagonal metallic gradient matching the SPAZE
   mockup. Fixed so it covers the viewport regardless of scroll; subtle enough that
   white cards stay legible on top. */
.bg-page {
    background: linear-gradient(155deg, #efe8d8 0%, #e5dac2 42%, #cfc09f 78%, #bfae8b 100%) fixed;
}
body { -webkit-tap-highlight-color: transparent; }

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: #cbd5e1 transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 9px; }

/* ---------------------------------------------------------------- Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
    font-weight: 500; font-size: .875rem; line-height: 1.25rem;
    padding: .55rem .9rem; border-radius: .65rem; border: 1px solid transparent;
    cursor: pointer; transition: background .15s, color .15s, border-color .15s, box-shadow .15s;
    white-space: nowrap; text-decoration: none;
}
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }
.btn[disabled], .btn.is-loading { opacity: .55; cursor: not-allowed; }
.btn-sm { padding: .38rem .65rem; font-size: .8rem; border-radius: .55rem; }
.btn-primary { background: var(--gold); color: var(--ink); font-weight: 600; }
.btn-primary:hover { background: var(--gold-dark); }

/* Gold accent chrome — unifies the interactive/attention accent (count badges,
   avatar/initial circles, selected chips) with the gold primary buttons. Semantic
   status pills (success/warning/danger) are intentionally NOT part of this. */
.badge-count { background: var(--gold); color: var(--ink); }
.avatar-accent { background: #ecdcb8; color: #6e5124; }
.chip-selected { background: var(--gold); color: var(--ink); border-color: var(--gold-dark) !important; }
.bg-gold { background: var(--gold) !important; }
.btn-secondary { background: #fff; color: #334155; border-color: #e2e8f0; }
.btn-secondary:hover { background: #f8fafc; }
.btn-danger { background: #dc2626; color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-ghost { background: transparent; color: #475569; }
.btn-ghost:hover { background: #f1f5f9; }

/* ----------------------------------------------------------------- Inputs */
.input, .select, .textarea {
    width: 100%; padding: .55rem .75rem; font-size: .875rem;
    border-radius: .65rem; border: 1px solid #e2e8f0; background: #fff; color: #0f172a;
    transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus {
    outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--ring);
}
.input::placeholder { color: #94a3b8; }
.input[readonly], .input:disabled { background: #f1f5f9; color: #64748b; }
.label { display: block; font-size: .8rem; font-weight: 500; color: #475569; margin-bottom: .35rem; }
.form-hint { font-size: .75rem; color: #94a3b8; margin-top: .3rem; }
.form-error { font-size: .75rem; color: #dc2626; margin-top: .3rem; }

/* Filter-bar fields: readable width on desktop, full-width stack on mobile.
   Used inside `flex flex-wrap items-end gap-3` toolbars (reports + list filters). */
.field { flex: 1 1 12rem; min-width: 12rem; }
.field > .input, .field > .select, .field > .textarea { width: 100%; }
.field-actions { flex: 1 1 100%; display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: flex-end; gap: .5rem; }
@media (max-width: 640px) {
    .field { flex-basis: 100%; min-width: 0; }
    .field-actions { justify-content: stretch; }
    .field-actions > .btn { flex: 1 1 auto; justify-content: center; }
}

/* ------------------------------------------------------------------ Cards */
.card { background: #fff; border: 1px solid #e8edf2; border-radius: 1rem; box-shadow: 0 1px 2px rgba(15,23,42,.04); }
.card-p { padding: 1.25rem; }

/* ------------------------------------------------------------------ Table */
.table-wrap { overflow-x: auto; border-radius: 1rem; }
.table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.table thead th {
    text-align: left; font-weight: 600; color: #64748b; background: #f8fafc;
    padding: .7rem .9rem; border-bottom: 1px solid #e2e8f0; white-space: nowrap;
}
.table tbody td { padding: .7rem .9rem; border-bottom: 1px solid #f1f5f9; color: #334155; vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #f8fafc; }
.table tfoot td { padding: .7rem .9rem; font-weight: 700; background: #f8fafc; border-top: 2px solid #e2e8f0; color: #0f172a; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.center { text-align: center !important; }

/* SweetAlert2 — recolor the default amber "warning" icon to neutral slate (no orange in the palette). */
.swal2-icon.swal2-warning { border-color: #cbd5e1; color: #475569; }

/* -------------------------------------------------------------- Select2 */
.select2-container { width: 100% !important; }
.select2-container--default .select2-selection--single {
    height: 2.5rem; border: 1px solid #cbd5e1; border-radius: .5rem; background: #fff;
    display: flex; align-items: center;
}
.select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 2.5rem; padding-left: .75rem; padding-right: 1.8rem; color: #0f172a;
}
.select2-container--default .select2-selection--single .select2-selection__arrow { height: 2.4rem; right: .4rem; }
.select2-container--default.select2-container--focus .select2-selection--single,
.select2-container--default.select2-container--open .select2-selection--single {
    border-color: #1e5b37; box-shadow: 0 0 0 2px rgba(30,91,55,.2);
}
.select2-dropdown { border-color: #cbd5e1; }
.select2-container--default .select2-results__option--highlighted[aria-selected] { background: #1e5b37; }
.select2-container--default .select2-results__option[aria-selected=true] { background: #d6e7dc; color: #184a2e; }
.select2-search--dropdown .select2-search__field { border: 1px solid #cbd5e1; border-radius: .375rem; }

/* Plain tables (dashboard previews, empty states) — inset from the card edge too.
   DataTables tables sit inside .dataTables_wrapper, so this only hits non-DT tables. */
.table-wrap:has(> table.table) { padding: .3rem 1.25rem .9rem; }

/* ----------------------------------------------------------- DataTables */
/* Inset the whole block (search + table + pagination) so it isn't flush with the card. */
.dataTables_wrapper { padding: .6rem 1.25rem .9rem; }
.dataTables_wrapper .dataTables_filter { padding: .1rem 0 .8rem; }
.dataTables_wrapper .dataTables_filter input {
    border: 1px solid #cbd5e1; border-radius: .5rem; padding: .4rem .7rem; margin-left: .4rem; outline: none;
}
.dataTables_wrapper .dataTables_filter input:focus { border-color: #1e5b37; box-shadow: 0 0 0 2px rgba(30,91,55,.2); }
.dataTables_wrapper .dataTables_info { color: #64748b; padding: .8rem 0 0; }
.dataTables_wrapper .dataTables_paginate { padding: .7rem 0 0; }
.dataTables_wrapper .dataTables_paginate .paginate_button {
    border-radius: .4rem !important; padding: .3rem .7rem !important; border: 1px solid transparent !important; background: transparent !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
    background: #1e5b37 !important; color: #fff !important; border-color: #1e5b37 !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: #f1f5f9 !important; color: #0f172a !important; border-color: #e2e8f0 !important;
}
.dataTables_wrapper .dataTables_filter, .dataTables_wrapper .dataTables_info { color: #64748b; }
/* DataTables sort icons shouldn't fight our header colours */
table.dataTable thead th { position: relative; }

/* -------------------------------------------------- Collapsible nav groups */
.nav-group-toggle { background: none; border: 0; cursor: pointer; }
.nav-group-toggle:hover .nav-group-chevron { color: #64748b; }
.nav-group-chevron { transition: transform .2s ease; }
.nav-group.is-collapsed .nav-group-chevron { transform: rotate(-90deg); }
/* Smooth height fold via animatable grid rows; collapses even without transition support. */
.nav-group-items { display: grid; grid-template-rows: 1fr; transition: grid-template-rows .2s ease; }
.nav-group.is-collapsed .nav-group-items { grid-template-rows: 0fr; }
.nav-group-items-inner { overflow: hidden; min-height: 0; }

/* --------------------------------------------------------- Custom sidebar colour */
/* Enabled by data-sidebar-custom on <html>; the --sb-* vars are emitted per-request
   in header.php from the admin's chosen colour. #id selectors outrank the sidebar's
   Tailwind utilities so the custom colour always wins.
   Active links carry .bg-brand-50; everything else is an inactive link. */
html[data-sidebar-custom] #sidebar {
    background-color: var(--sb-bg);
    border-right-color: var(--sb-border);
    color: var(--sb-fg-muted);
}
html[data-sidebar-custom] #sidebar .border-b { border-bottom-color: var(--sb-border); }
html[data-sidebar-custom] #sidebar .leading-tight > div:first-child { color: var(--sb-fg); }
html[data-sidebar-custom] #sidebar .leading-tight > div:last-child,
html[data-sidebar-custom] #sidebar .nav-group-toggle span,
html[data-sidebar-custom] #sidebar .nav-group-chevron { color: var(--sb-fg-muted); }
html[data-sidebar-custom] #sidebar a { color: var(--sb-fg-muted); }
html[data-sidebar-custom] #sidebar a:not(.bg-brand-50):hover {
    background-color: var(--sb-hover-bg);
    color: var(--sb-fg);
}
html[data-sidebar-custom] #sidebar a.bg-brand-50 {
    background-color: var(--sb-active-bg);
    color: var(--sb-fg);
}

/* ------------------------------------ Topbar background (mobile = page bg) */
/* On mobile the topbar blends into the page gradient; on desktop it gets the
   frosted-glass treatment so content scrolling underneath stays readable. */
.app-topbar {
    background: linear-gradient(155deg, #efe8d8 0%, #e5dac2 42%, #cfc09f 78%, #bfae8b 100%) fixed;
}
@media (min-width: 1024px) {
    .app-topbar {
        background: rgb(255 255 255 / 0.9);
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
    }
}

/* ------------------------------------------------ Desktop sidebar collapse */
/* PC only — hide the sidebar and widen the content. Mobile (< lg) is untouched:
   it keeps the slide-in overlay toggle, so this class has no effect there. */
.app-main { transition: padding-left .2s ease; }
@media (min-width: 1024px) {
    html.sidebar-collapsed #sidebar { transform: translateX(-100%); }
    html.sidebar-collapsed .app-main { padding-left: 0; }
}

/* --------------------------------------------------------- Page fade-in */
/* Content fades/slides in on every page load. Respects reduced-motion. */
@media (prefers-reduced-motion: no-preference) {
    .app-main > main { animation: page-fade .35s ease both; }
}
@keyframes page-fade {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: none; }
}

/* ------------------------------------------------------------------ Print */
@media print {
    .no-print, #sidebar, header.sticky, footer { display: none !important; }
    .dataTables_filter, .dataTables_info, .dataTables_paginate, .dataTables_length { display: none !important; }
    body { background: #fff !important; color: #000 !important; }
    .lg\:pl-64 { padding-left: 0 !important; }
    .print-area { box-shadow: none !important; border: none !important; }
    main { padding: 0 !important; }
}

/* ----------------------------------------------- Rendered markdown (.md-body)
   Blogger-style typography for portfolio post bodies. This is raw HTML output
   from Parsedown (sanitized server-side). */
.md-body { font-size: 1.05rem; line-height: 1.8; color: #1f2937; word-wrap: break-word; }
.md-body > :first-child { margin-top: 0; }
.md-body h1 { font-size: 1.75rem; font-weight: 700; margin: 2rem 0 .8rem; color: #0f172a; }
.md-body h2 { font-size: 1.5rem; font-weight: 700; margin: 2rem 0 .8rem; color: #0f172a; }
.md-body h3 { font-size: 1.2rem; font-weight: 700; margin: 1.6rem 0 .6rem; color: #0f172a; }
.md-body h4 { font-size: 1.05rem; font-weight: 700; margin: 1.2rem 0 .5rem; color: #0f172a; }
.md-body p  { margin: 0 0 1rem; }
.md-body ul, .md-body ol { margin: 0 0 1rem 1.4rem; }
.md-body ul { list-style: disc; }
.md-body ol { list-style: decimal; }
.md-body li { margin: .25rem 0; }
.md-body blockquote {
    border-left: 4px solid #1e5b37; background: #eef5ef; color: #184a2e;
    padding: .6rem 1rem; border-radius: .5rem; margin: 0 0 1rem;
}
.md-body a { color: #1e5b37; text-decoration: underline; }
.md-body a:hover { color: #184a2e; }
.md-body code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9em;
    background: #f1f5f9; padding: .12rem .4rem; border-radius: .35rem;
}
.md-body pre { background: #0f172a; color: #e2e8f0; padding: 1rem; border-radius: .65rem; overflow-x: auto; margin: 0 0 1rem; }
.md-body pre code { background: none; padding: 0; color: inherit; font-size: .85rem; }
.md-body img { max-width: 100%; height: auto; border-radius: .65rem; margin: 0 0 1rem; }
/* Inline video players (YouTube/Vimeo iframe or direct <video>) — responsive 16:9 */
.md-body .md-embed { position: relative; width: 100%; aspect-ratio: 16 / 9; margin: 0 0 1.25rem; border-radius: .65rem; overflow: hidden; background: #000; }
.md-body .md-embed iframe, .md-body .md-embed video { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.md-body .md-embed-video video { object-fit: contain; }
.md-body hr { border: 0; border-top: 1px solid #e2e8f0; margin: 1.5rem 0; }
.md-body table { width: 100%; border-collapse: collapse; margin: 0 0 1rem; }
.md-body th, .md-body td { border: 1px solid #e2e8f0; padding: .5rem .7rem; text-align: left; }
.md-body th { background: #f8fafc; font-weight: 600; }


/* ------------------------------------------- EasyMDE editor (pro post form)
   Fit the vendored editor into the app's input/card look. */
.EasyMDEContainer { max-width: 100%; }
.EasyMDEContainer .editor-toolbar { border-color: #e2e8f0; background: #f8fafc; border-radius: .65rem .65rem 0 0; }
.EasyMDEContainer .CodeMirror { border-color: #e2e8f0; border-radius: 0 0 .65rem .65rem; background: #fff; color: #0f172a; }
.EasyMDEContainer .editor-preview { background: #fff; padding: 1rem; }

/* ------------------------------------------------------- Corner status ribbon
   Folded-paper ribbon pinned to a card's top-right corner (bay picker: busy /
   inactive). The outer box clips to a small square so the rotated strip reads
   as "wrapping" the corner; the ::before/::after triangles are a darker shade
   of the same colour to fake the paper fold where the strip exits the square. */
.corner-ribbon { position: absolute; top: -2px; right: -2px; width: 90px; height: 90px; overflow: hidden; z-index: 10; pointer-events: none; }
.corner-ribbon::before, .corner-ribbon::after { position: absolute; z-index: -1; content: ""; display: block; border: 3px solid; }
.corner-ribbon::before { top: 0; left: 3px; }
.corner-ribbon::after  { bottom: 3px; right: 0; }
.corner-ribbon span {
    position: absolute; display: block; width: 130px; padding: 8px 0; left: -15px; top: 18px;
    transform: rotate(45deg); text-align: center; font-size: 11px; font-weight: 700; line-height: 1.2;
    color: #fff; box-shadow: 0 3px 6px rgba(15, 23, 42, .25); text-shadow: 0 1px 1px rgba(0, 0, 0, .15);
}
.corner-ribbon.is-inactive::before, .corner-ribbon.is-inactive::after { border-color: #475569; }
.corner-ribbon.is-inactive span { background: #64748b; }
.corner-ribbon.is-busy::before, .corner-ribbon.is-busy::after { border-color: #b45309; }
.corner-ribbon.is-busy span { background: #d97706; }
.corner-ribbon.is-free::before, .corner-ribbon.is-free::after { border-color: #047857; }
.corner-ribbon.is-free span { background: #059669; }

/* ------------------------------------------------ Icon picker (menu manager)
   A radio group rendered as selectable tiles. Written by hand because the
   pre-built tailwind.css ships only the utilities already used in the app —
   peer-checked/sr-only aren't in it. */
.icon-pick { display: inline-flex; cursor: pointer; }
.icon-pick input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.icon-pick > span {
    display: flex; align-items: center; justify-content: center;
    width: 2.75rem; height: 2.75rem; border-radius: .5rem;
    border: 1px solid #e2e8f0; color: #64748b; transition: all .15s ease;
}
.icon-pick > span svg { width: 1.25rem; height: 1.25rem; }
.icon-pick:hover > span { border-color: #cbd5e1; color: #334155; }
.icon-pick input:checked + span { border-color: #1e5b37; background: #eef5ef; color: #184a2e; }
.icon-pick input:focus-visible + span { outline: 2px solid #1e5b37; outline-offset: 2px; }
