@font-face { font-family: 'Lama Sans'; src: url(/fonts/LamaSans-Regular.otf) format('opentype'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Lama Sans'; src: url(/fonts/LamaSans-Medium.otf) format('opentype'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Lama Sans'; src: url(/fonts/LamaSans-Bold.otf) format('opentype'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Lama Sans'; src: url(/fonts/LamaSans-Black.otf) format('opentype'); font-weight: 900; font-display: swap; }

/* Tokens taken from almanasa.iq */
:root {
  --bg: #000;
  --surface: #0d0d14;
  --card: #1a1923;
  --card-2: #20202c;
  --line: #2c2b36;
  --text: #fff;
  --text-2: #e0e0e0;
  --muted: #838389;
  --primary: #00d5d5;
  --primary-soft: #00d5d51f;
  --primary-hover: #33e0e0;
  --teal-deep: #05515c;
  --danger: #ff5a5f;
  --radius: 8px;
  --radius-lg: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  background-image: radial-gradient(1200px 500px at 85% -10%, #05515c55, transparent 60%),
                    radial-gradient(900px 400px at -10% 110%, #3a060a55, transparent 60%);
  background-attachment: fixed;
  color: var(--text-2);
  font-family: 'Lama Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h2 { margin: 0; font-size: 17px; font-weight: 700; color: var(--text); }
.muted { color: var(--muted); font-weight: 400; }
[hidden] { display: none !important; }

/* ── Top bar ─────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px 32px; border-bottom: 1px solid var(--line);
  background: #000c; backdrop-filter: blur(12px);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-logo { width: 44px; height: 44px; border-radius: 10px; }
.brand-title { font-weight: 900; font-size: 20px; color: var(--text); line-height: 1.1; }
.brand-sub { color: var(--muted); font-size: 13px; }
.topbar-note b { color: var(--text); font-variant-numeric: tabular-nums; }
.topbar-note.warn { color: #ffcd7a; border-color: #ffb02e66; background: #ffb02e1a; }
.topbar-note.over { color: #ffc9cb; border-color: #ff5a5f77; background: #ff5a5f1f; }
.banner.limit-banner { background: #ffb02e14; border-color: #ffb02e55; color: #ffe2b0; }
.banner.limit-banner.over { background: #ff5a5f1a; border-color: #ff5a5f55; color: #ffc9cb; }
button:disabled, input:disabled, select:disabled { opacity: .45; cursor: not-allowed; }
/* At the daily limit, pause the controls that spend tokens (the server refuses them anyway). */
body.limit-reached .date-row > *, body.limit-reached .finder-filters > * { pointer-events: none; opacity: .45; }
.topbar-note {
  white-space: nowrap; color: var(--primary); font-weight: 700; font-size: 13px; letter-spacing: .02em;
  padding: 6px 12px; border: 1px solid #00d5d555; border-radius: 999px; background: var(--primary-soft);
}

.banner {
  margin: 16px 32px 0; padding: 12px 16px; border-radius: var(--radius);
  background: #ff5a5f1a; border: 1px solid #ff5a5f55; color: #ffc9cb;
}

/* ── Layout ──────────────────────────────────────────── */
.layout {
  display: grid; grid-template-columns: minmax(360px, 440px) 1fr; gap: 24px;
  padding: 24px 32px 48px; max-width: 1360px; margin: 0 auto;
}
.panel { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.card {
  background: linear-gradient(180deg, #1a1923, #16151e);
  border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 20px;
}
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.step {
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  background: var(--primary); color: #000; font-weight: 900; font-size: 14px;
}

/* ── Inputs ──────────────────────────────────────────── */
.input {
  width: 100%; height: 42px; padding: 0 12px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line); outline: none;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
select.input { appearance: none; padding-right: 32px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 17px) 18px, calc(100% - 12px) 18px; background-size: 5px 5px; background-repeat: no-repeat; }

.field { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.card-head + .field { margin-top: 0; }
.field-label { font-size: 13px; font-weight: 700; color: var(--text-2); }

.icon-btn {
  flex: none; width: 42px; height: 42px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line); font-size: 20px; line-height: 1;
}
.icon-btn:hover { border-color: var(--primary); color: var(--primary); }
.chip-btn {
  flex: none; height: 42px; padding: 0 14px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line); color: var(--muted); font-weight: 700;
}
.chip-btn:hover { border-color: var(--primary); color: var(--primary); }
.chip-btn.active { background: var(--primary-soft); border-color: #00d5d555; color: var(--primary); }

.primary-btn {
  width: 100%; min-height: 52px; border: none; border-radius: var(--radius);
  background: var(--primary); color: #000; font-weight: 700; font-size: 17px;
  transition: background .15s, transform .05s;
}
.primary-btn:hover:not(:disabled) { background: var(--primary-hover); }
.primary-btn:active:not(:disabled) { transform: translateY(1px); }
.primary-btn:disabled { background: #2c2b36; color: var(--muted); cursor: not-allowed; }
.secondary-btn {
  width: 100%; min-height: 52px; border-radius: var(--radius); font-weight: 700; font-size: 16px;
  background: transparent; border: 1px solid var(--primary); color: var(--primary);
}
.secondary-btn:hover:not(:disabled) { background: var(--primary-soft); }
.secondary-btn:disabled { border-color: var(--line); color: var(--muted); cursor: not-allowed; }

/* Segmented control */
.segmented { display: flex; gap: 4px; padding: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.segmented button {
  flex: 1; height: 36px; border: none; border-radius: 7px; background: transparent;
  color: var(--muted); font-weight: 700; font-size: 14px; white-space: nowrap;
}
.segmented button:hover { color: var(--text); }
.segmented button.active { background: var(--primary); color: #000; }
.segmented.small button { height: 30px; font-size: 13px; padding: 0 12px; }

/* Tabs */
.tabs { display: flex; gap: 20px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tab {
  background: none; border: none; padding: 0 0 10px; color: var(--muted); font-weight: 700;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab.active { color: var(--primary); border-color: var(--primary); }

/* Toggles */
.toggles { display: flex; flex-direction: column; gap: 4px; margin-top: 16px; }
.toggle { display: flex; align-items: center; gap: 12px; padding: 8px 0; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle .switch {
  flex: none; width: 40px; height: 24px; border-radius: 999px; background: var(--line); position: relative; transition: background .15s;
}
.toggle .switch::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; transition: transform .15s;
}
.toggle input:checked + .switch { background: var(--primary); }
.toggle input:checked + .switch::after { transform: translateX(16px); background: #000; }
.toggle input:focus-visible + .switch { box-shadow: 0 0 0 3px var(--primary-soft); }
.toggle b { display: block; color: var(--text); font-weight: 700; font-size: 14px; }
.toggle small { display: block; color: var(--muted); font-size: 12px; }

/* ── Fixtures ────────────────────────────────────────── */
.date-row { position: relative; display: flex; gap: 8px; margin-bottom: 14px; }

/* Date picker */
/* The calendar anchors to the whole date row so it never overflows on phones. */
.datepicker { flex: 1; min-width: 0; }
.date-trigger {
  width: 100%; height: 42px; display: flex; align-items: center; gap: 10px; padding: 0 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--text); font-weight: 500; text-align: start;
}
.date-trigger svg { flex: none; color: var(--primary); }
.date-trigger:hover, .date-trigger[aria-expanded='true'] { border-color: var(--primary); }
.date-trigger:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--primary-soft); border-color: var(--primary); }
.date-label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.date-day.relative { color: var(--primary); font-weight: 700; }
.calendar {
  position: absolute; top: calc(100% + 8px); left: 50%; transform: translateX(-50%); z-index: 30;
  width: min(320px, 100%); padding: 14px; border-radius: var(--radius-lg);
  background: #15141d; border: 1px solid var(--line); box-shadow: 0 18px 50px #000c;
}
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal-title { font-weight: 700; color: var(--text); font-size: 15px; }
.cal-nav {
  width: 34px; height: 34px; display: grid; place-items: center; border-radius: var(--radius);
  background: transparent; border: 1px solid transparent; color: var(--text-2);
}
.cal-nav:hover { border-color: var(--line); color: var(--primary); background: var(--surface); }
.cal-weekdays, .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-weekdays span { text-align: center; font-size: 11px; font-weight: 700; color: var(--muted); padding: 4px 0 6px; }
.cal-day {
  aspect-ratio: 1; display: grid; place-items: center; border-radius: 9px; border: none;
  background: transparent; color: var(--text); font-size: 14px; font-weight: 500; font-variant-numeric: tabular-nums;
}
.cal-day:hover { background: var(--card-2); }
.cal-day:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.cal-day.outside { color: #4a4955; }
.cal-day.today { box-shadow: inset 0 0 0 1.5px var(--primary); color: var(--primary); font-weight: 700; }
.cal-day.selected { background: var(--primary); color: #000; font-weight: 700; box-shadow: none; }
.cal-foot { display: flex; justify-content: center; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.cal-today { background: none; border: none; color: var(--primary); font-weight: 700; font-size: 13px; padding: 4px 8px; border-radius: 6px; }
.cal-today:hover { background: var(--primary-soft); }
.fixtures { display: flex; flex-direction: column; gap: 14px; max-height: 460px; overflow-y: auto; padding-right: 4px; }
.fixtures::-webkit-scrollbar, .team-grid::-webkit-scrollbar { width: 6px; }
.fixtures::-webkit-scrollbar-thumb, .team-grid::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }
.league-group-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; font-size: 13px; }
.league-group-head img { width: 20px; height: 20px; object-fit: contain; }
.league-group-head b { color: var(--text); }
.league-group-head .ar { color: var(--muted); margin-inline-start: auto; direction: rtl; }
.fixture {
  width: 100%; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px;
  padding: 10px 12px; margin-bottom: 6px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line); text-align: start;
}
.fixture:hover { border-color: #00d5d577; }
.fixture.selected { border-color: var(--primary); background: #00d5d514; box-shadow: inset 0 0 0 1px var(--primary); }
.fixture .team { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 14px; font-weight: 500; color: var(--text); }
.fixture .team.away { flex-direction: row-reverse; text-align: end; }
.fixture .team span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fixture img { width: 26px; height: 26px; object-fit: contain; flex: none; }
.fixture .time { font-weight: 700; color: var(--primary); font-size: 13px; text-align: center; min-width: 48px; }
.fixture .time small { display: block; color: var(--muted); font-weight: 500; font-size: 11px; }

.empty { padding: 28px 12px; text-align: center; color: var(--muted); font-size: 14px; }
.loading-row { height: 48px; border-radius: var(--radius); margin-bottom: 6px;
  background: linear-gradient(90deg, var(--surface) 0%, #1f1e29 50%, var(--surface) 100%); background-size: 200% 100%;
  animation: shimmer 1.2s infinite linear; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ── Team picker ─────────────────────────────────────── */
.slots { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: stretch; }
.swap { align-self: center; }
.slot {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 8px; min-height: 124px;
  background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius-lg); text-align: center;
}
.slot:hover { border-color: #00d5d577; }
.slot.active { border: 1px solid var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.slot.filled { border-style: solid; }
.slot-label { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.slot-body { display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--text); font-weight: 700; font-size: 14px; line-height: 1.25; }
.slot-body img { width: 52px; height: 52px; object-fit: contain; }
.slot-body .plus { width: 52px; height: 52px; border-radius: 50%; border: 1px dashed var(--muted); display: grid; place-items: center; font-size: 24px; color: var(--muted); font-weight: 400; }
.slot-body .hint { color: var(--muted); font-weight: 500; font-size: 13px; }

.finder { margin-top: 12px; padding: 12px; border-radius: var(--radius-lg); background: #0b0b11; border: 1px solid var(--line); }
.finder-head { font-size: 13px; font-weight: 700; color: var(--primary); margin-bottom: 10px; }
.finder-filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.team-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 6px; max-height: 300px; overflow-y: auto; padding-right: 4px; }
.team-grid .section { grid-column: 1 / -1; font-size: 12px; color: var(--muted); font-weight: 700; margin: 6px 0 2px; }
.team-card {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 6px;
  background: var(--card-2); border: 1px solid transparent; border-radius: var(--radius); font-size: 12.5px; color: var(--text); line-height: 1.2; text-align: center;
}
.team-card:hover { border-color: var(--primary); }
.team-card.current { border-color: var(--primary); background: #00d5d514; }
.team-card img { width: 38px; height: 38px; object-fit: contain; }

/* ── Preview ─────────────────────────────────────────── */
.preview-card { display: flex; flex-direction: column; gap: 14px; }
.preview-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.stage {
  position: relative; border-radius: var(--radius-lg); border: 1px solid var(--line);
  display: grid; place-items: center; padding: 24px; min-height: 420px; overflow: hidden; transition: background-color .2s;
}
.stage.bg-grid {
  background-color: #1b1b22;
  background-image:
    linear-gradient(45deg, #25252e 25%, transparent 25%), linear-gradient(-45deg, #25252e 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #25252e 75%), linear-gradient(-45deg, transparent 75%, #25252e 75%);
  background-size: 24px 24px; background-position: 0 0, 0 12px, 12px -12px, -12px 0;
}
.stage.bg-light { background: linear-gradient(135deg, #e9e6f2, #cfd8e3); }
.stage.bg-dark { background: linear-gradient(135deg, #1c1c24, #2d2438); }
#output { max-width: 100%; max-height: 560px; width: auto; height: auto; display: block; }

.placeholder { text-align: center; color: var(--muted); }
.placeholder-art { display: flex; align-items: center; justify-content: center; gap: 18px; margin-bottom: 14px; }
.placeholder-art span { width: 88px; height: 100px; border: 2px dashed #3a3946; border-radius: 16px 16px 44px 44px; }

.busy { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; background: #000a; backdrop-filter: blur(3px); color: var(--text); font-weight: 700; }
.spinner { width: 36px; height: 36px; border-radius: 50%; border: 3px solid #00d5d533; border-top-color: var(--primary); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.meta-row { display: flex; align-items: center; justify-content: space-between; min-height: 24px; font-size: 13px; }
.badge { white-space: nowrap; font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px; background: var(--primary-soft); color: var(--primary); border: 1px solid #00d5d555; }
.badge.warn { background: #ffb02e1a; color: #ffcd7a; border-color: #ffb02e55; }
.actions { display: grid; grid-template-columns: 2fr 1fr; gap: 10px; }

/* Notification mock (iOS-style, like the CMS reference screenshot) */
.notif-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.notif-wall { border-radius: var(--radius-lg); padding: 18px 12px; }
.notif-wall.light { background: linear-gradient(160deg, #9aa7d6, #d9a5c4 60%, #f0c9a6); }
.notif-wall.dark { background: linear-gradient(160deg, #0f1733, #2c1640 60%, #3e1b26); }
.notif { display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 20px; }
.light .notif { background: #ffffffb3; color: #111; backdrop-filter: blur(20px); }
.dark .notif { background: #1e1e24c7; color: #fff; backdrop-filter: blur(20px); }
.notif-app { width: 38px; height: 38px; border-radius: 9px; flex: none; }
.notif-text { flex: 1; min-width: 0; font-family: -apple-system, 'SF Pro Text', system-ui, sans-serif; font-size: 13px; line-height: 1.3; }
.notif-top { display: flex; justify-content: space-between; gap: 8px; }
.notif-top span { opacity: .55; font-size: 12px; }
.notif-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notif-body { opacity: .85; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.notif-thumb { width: 44px; height: 44px; flex: none; }
.hint-text { margin: 12px 0 0; font-size: 13px; color: #ffcd7a; }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 50;
  padding: 12px 18px; border-radius: var(--radius); background: var(--primary); color: #000; font-weight: 700;
  box-shadow: 0 10px 30px #0008;
}
.toast.error { background: var(--danger); color: #fff; }

/* ── Login ───────────────────────────────────────────── */
.login-page { display: grid; place-items: center; padding: 24px 16px; }
.login-card {
  width: min(400px, 100%); padding: 32px 28px; border-radius: var(--radius-lg);
  background: linear-gradient(180deg, #1a1923, #16151e); border: 1px solid var(--line);
  box-shadow: 0 24px 60px #0009; text-align: center;
}
.login-logo { width: 64px; height: 64px; border-radius: 14px; }
.login-card h1 { margin: 16px 0 4px; font-size: 22px; font-weight: 900; color: var(--text); }
.login-card > p { margin: 0 0 20px; font-size: 14px; }
.login-card form { text-align: start; display: flex; flex-direction: column; }
.login-card .primary-btn { margin-top: 20px; }
.login-error { margin: 14px 0 0; padding: 10px 12px; border-radius: var(--radius); background: #ff5a5f1a; border: 1px solid #ff5a5f55; color: #ffc9cb; font-size: 14px; }

.user-box { display: flex; align-items: center; gap: 10px; }
.user-name { color: var(--muted); font-size: 13px; white-space: nowrap; }
.user-name b { color: var(--text-2); }
.logout-btn {
  height: 34px; padding: 0 12px; border-radius: var(--radius); background: transparent;
  border: 1px solid var(--line); color: var(--text-2); font-weight: 700; font-size: 13px;
}
.logout-btn:hover { border-color: var(--primary); color: var(--primary); }

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 1000px) {
  .layout { grid-template-columns: 1fr; padding: 16px; }
  .topbar { padding: 12px 16px; }
  .banner { margin: 12px 16px 0; }
}
@media (max-width: 560px) {
  .user-name { display: none; }
  .date-trigger svg { display: none; }
  .date-trigger { justify-content: center; padding: 0 8px; }
  .notif-grid { grid-template-columns: 1fr; }
  .actions { grid-template-columns: 1fr; }
  .stage { min-height: 300px; padding: 12px; }
}
