/* ==========================================================================
   AHL UI – global dark theme (auto-supports light via prefers-color-scheme)
   Place at: /static/style.css
   ========================================================================== */

/* ---- CSS Reset / Base --------------------------------------------------- */
*,
*::before,
*::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

:root {
  /* Dark theme tokens */
  --bg: #0c0f14;
  --bg-elev-1: #12161d;
  --bg-elev-2: #171c24;
  --line: #242a34;
  --fg: #e9edf3;
  --muted: #9aa6b2;
  --chip: #1d2430;
  --brand: #7aa2ff;       /* soft blue accent */
  --brand-strong: #5b86ff;
  --danger: #ff5c7a;
  --success: #3bd671;
  --warning: #ffcc66;

  --radius-lg: 14px;
  --radius-md: 10px;
  --radius-sm: 8px;

  --shadow-1: 0 6px 24px rgba(0,0,0,.26), 0 2px 8px rgba(0,0,0,.3);
  --shadow-2: 0 10px 30px rgba(0,0,0,.35);

  --container-w: 1120px;

  --focus: 0 0 0 3px rgba(122,162,255,.33);

  --font: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji", sans-serif;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #fff;
    --bg-elev-1: #fff;
    --bg-elev-2: #fafafa;
    --line: #e5e7eb;
    --fg: #0f172a;
    --muted: #6b7280;
    --chip: #f3f4f6;
    --brand: #335dff;
    --brand-strong: #1f46ff;

    --shadow-1: 0 4px 14px rgba(0,0,0,.08), 0 2px 8px rgba(0,0,0,.06);
    --shadow-2: 0 10px 24px rgba(0,0,0,.10);
  }
}

body {
  background: radial-gradient(1200px 800px at 10% -10%, rgba(90,110,160,.08), transparent),
              radial-gradient(1200px 800px at 110% 10%, rgba(90,160,120,.06), transparent),
              var(--bg);
  color: var(--fg);
  font-family: var(--font);
  line-height: 1.45;
}

/* ---- Layout helpers ----------------------------------------------------- */
.container {
  max-width: var(--container-w);
  margin: 2rem auto;
  padding: 0 1rem;
}

.row { display:flex; gap:.9rem; align-items:center; flex-wrap:wrap; }
.flex { display:flex; gap:.6rem; align-items:center; flex-wrap:wrap; }
.hidden { display: none !important; }

/* ---- Typography ---------------------------------------------------------- */
h1, h2, h3 { margin: 0 0 .75rem; letter-spacing: .2px; }
h1 { font-size: clamp(1.35rem, 1vw + 1rem, 1.8rem); font-weight: 700; }
h2 { font-size: clamp(1.1rem, .6vw + .9rem, 1.4rem); font-weight: 650; }
h3 { font-size: 1.05rem; font-weight: 600; }

.small { color: var(--muted); font-size: .92rem; }

/* ---- Cards / Surfaces ---------------------------------------------------- */
.card {
  background: linear-gradient(180deg, var(--bg-elev-1), var(--bg-elev-2));
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1rem;
  margin: .9rem 0;
  box-shadow: var(--shadow-1);
}

.card--tight { padding: .75rem; }

/* ---- Buttons ------------------------------------------------------------- */
.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: .6rem .95rem;
  background: var(--brand);
  color: #fff;
  cursor: pointer;
  font-weight: 600;
  letter-spacing: .2px;
  transition: transform .06s ease, box-shadow .15s ease, background .2s ease, border-color .2s ease;
  box-shadow: 0 4px 14px rgba(122,162,255,.25);
}
.btn:hover { background: var(--brand-strong); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:focus-visible { outline: none; box-shadow: var(--focus); }

.btn.secondary {
  background: transparent;
  color: var(--fg);
  border-color: var(--line);
  box-shadow: none;
}
.btn.secondary:hover { background: rgba(255,255,255,.04); }

.btn.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}
.btn.ghost:hover { color: var(--fg); background: rgba(255,255,255,.03); }

.btn:disabled { opacity:.5; cursor:not-allowed; }

/* Icon button (optional) */
.icon-btn {
  width: 36px; height: 36px; display:inline-grid; place-items:center;
  border-radius: 10px; border: 1px solid var(--line); background: transparent; color: var(--fg);
}
.icon-btn:hover { background: rgba(255,255,255,.04); }

/* ---- Inputs / Forms ------------------------------------------------------ */
label { font-weight: 600; display:block; margin:.6rem 0 .35rem; color: var(--fg); }

input, select, textarea {
  width: 100%;
  background: var(--bg-elev-2);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: .6rem .7rem;
  transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}
input::placeholder, textarea::placeholder { color: #7c8794; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: var(--focus);
}

.inline-field { max-width: 260px; }

/* Radio/checkbox alignment */
.inline-choice { display:flex; gap:.5rem; align-items:center; }

/* ---- Lists / Grids ------------------------------------------------------- */
.list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: .85rem;
}

.item {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: .75rem;
  display:flex; gap:.75rem; align-items:center;
  background: linear-gradient(180deg, var(--bg-elev-1), var(--bg-elev-2));
  transition: background .15s ease, transform .06s ease, border-color .2s ease;
  cursor: pointer;
}
.item:hover { background: #1d2430; transform: translateY(-1px); }
.item img { width: 42px; height: 42px; object-fit: contain; }

.badge {
  display:inline-block; padding:.18rem .5rem; border-radius:999px;
  background: var(--chip); color: var(--fg); border: 1px solid var(--line);
  font-size: .82rem;
}

/* Link chips / quick links area */
.links a {
  text-decoration: none;
  border: 1px solid var(--line);
  padding: .48rem .66rem;
  border-radius: 10px;
  background: var(--bg-elev-2);
  color: var(--fg);
  transition: background .2s ease, transform .06s ease, border-color .2s ease;
}
.links a:hover { background: #1d2430; transform: translateY(-1px); }

/* ---- Top bar / Nav ------------------------------------------------------- */
.topbar {
  display:flex; align-items:center; justify-content:space-between;
  gap:.75rem; margin-bottom: 1rem;
}
.brand { color: var(--muted); font-weight: 600; letter-spacing:.3px; }

/* ---- Spinner ------------------------------------------------------------- */
.spinner {
  display:inline-block; width:16px; height:16px;
  border:2px solid rgba(255,255,255,.35);
  border-top-color: transparent;
  border-radius:50%;
  animation: spin .9s linear infinite;
  vertical-align: middle; margin-left:.4rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Tables (if you render any) ----------------------------------------- */
.table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: var(--bg-elev-2);
}
.table th, .table td {
  padding: .7rem .8rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
}
.table thead th {
  background: var(--bg-elev-1);
  color: var(--muted);
  font-weight: 600;
}
.table tr:hover td { background: rgba(255,255,255,.02); }

/* ---- Code / KBD ---------------------------------------------------------- */
code, kbd {
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
  padding: .15rem .35rem;
  border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: .92em;
  color: var(--fg);
}

/* ---- Forms: error text / helpers ---------------------------------------- */
.help { color: var(--muted); font-size: .9rem; }
.error { color: var(--danger); font-size: .92rem; }

/* ---- Footer -------------------------------------------------------------- */
footer { margin-top: 1.5rem; color: var(--muted); font-size: .92rem; }

/* ---- Scrollbar (WebKit) -------------------------------------------------- */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb {
  background: #2a3342; border-radius: 10px; border: 2px solid transparent; background-clip: content-box;
}
*::-webkit-scrollbar-track { background: transparent; }

/* ---- Utilities ----------------------------------------------------------- */
.max-w-200 { max-width: 200px; }
.max-w-160 { max-width: 160px; }
.mt-4 { margin-top: .25rem; }
.mt-8 { margin-top: .5rem; }
.mt-12 { margin-top: .75rem; }
.ml-auto { margin-left: auto; }

/* ---- Responsive tweaks --------------------------------------------------- */
@media (max-width: 680px) {
  .topbar { flex-direction: column; align-items: stretch; gap: .5rem; }
  .inline-field { max-width: 100%; }
}

/* ---- Login layout helpers (used by login.html) --------------------------- */
.login-wrap {
  max-width: 540px;
  margin: 6vh auto;
  padding: 0 1rem;
}
.login-card {
  background: linear-gradient(180deg, var(--bg-elev-1), var(--bg-elev-2));
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-2);
  padding: 1rem;
}

/* ---- Header buttons area in UI ------------------------------------------ */
.header-actions { display:flex; gap:.5rem; align-items:center; }

/*  ----- PENALTY EDITOR -------- */
.table { width:100%; border-collapse: collapse; }
.table th, .table td { border:1px solid var(--line); padding:.5rem; }
.table thead th { position: sticky; top:0; background: #111; color:#fff; }
.table .editable { width:100%; padding:.4rem .5rem; border:1px solid #444; border-radius:8px; background:#0f0f0f; color:#fff; }