/* ── Variables ───────────────────────────────────────────────── */
:root {
  --bg:         #080c14;
  --bg-card:    #0f1520;
  --bg-raised:  #151d2e;
  --border:     #1e2a3a;
  --border-glow:#2a4060;
  --accent:     #00e5ff;
  --accent2:    #7c3aed;
  --green:      #22c55e;
  --red:        #ef4444;
  --yellow:     #f59e0b;
  --text:       #e8edf5;
  --text-muted: #6b7a94;
  --text-dim:   #3d4f68;
  --gk-color:   #f59e0b;
  --def-color:  #22c55e;
  --mid-color:  #3b82f6;
  --str-color:  #ef4444;
  --radius:     8px;
  --radius-lg:  14px;
  --font-display: 'Bebas Neue', sans-serif;
  --font-body:    'Inter', sans-serif;
  --shadow:     0 4px 24px rgba(0,0,0,0.4);
  --glow:       0 0 20px rgba(0,229,255,0.12);
}

/* ── Reset ───────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }  /* base bumped from 15px — scales all rem-based sizing up ~7% */
body { background: var(--bg); color: var(--text); font-family: var(--font-body); line-height: 1.6; min-height: 100vh; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
input, select, textarea { font-family: var(--font-body); }

/* ── Navbar ──────────────────────────────────────────────────── */
.navbar {
  display: flex; align-items: center; gap: 2rem;
  background: rgba(8,12,20,0.95); border-bottom: 1px solid var(--border);
  padding: 0 2rem; height: 60px; position: sticky; top: 0; z-index: 100;
  backdrop-filter: blur(12px);
}
.navbar-brand { display: flex; align-items: center; gap: .6rem; flex-shrink: 0; }
.brand-icon { font-size: 1.4rem; }
.brand-text { font-family: var(--font-display); font-size: 1.35rem; letter-spacing: 0.08em; color: var(--text); }
.brand-text span { color: var(--accent); }
.navbar-nav { display: flex; list-style: none; gap: .25rem; flex: 1; }
.nav-link { color: var(--text-muted); padding: .4rem .9rem; border-radius: var(--radius); font-size: .875rem; font-weight: 500; transition: all .2s; }
.nav-link:hover, .nav-link.active { color: var(--text); background: var(--bg-raised); text-decoration: none; }
.nav-link.active { color: var(--accent); }
.navbar-user { display: flex; align-items: center; gap: .75rem; flex-shrink: 0; }
.user-name { font-size: .8rem; color: var(--text-muted); }
.btn-logout { background: transparent; border: 1px solid var(--border); color: var(--text-muted); padding: .35rem .8rem; border-radius: var(--radius); cursor: pointer; font-size: .8rem; transition: all .2s; }
.btn-logout:hover { border-color: var(--red); color: var(--red); }

/* ── Main Content ────────────────────────────────────────────── */
.main-content { max-width: 1300px; margin: 0 auto; padding: 2rem 1.5rem; }
.main-content.no-nav { max-width: 480px; padding-top: 6rem; }

/* ── Alerts ──────────────────────────────────────────────────── */
.alert { padding: .75rem 1.25rem; border-radius: var(--radius); margin-bottom: 1.25rem; font-size: .9rem; font-weight: 500; }
.alert-success { background: rgba(34,197,94,.12); border: 1px solid rgba(34,197,94,.3); color: var(--green); }
.alert-warning { background: rgba(245,158,11,.12); border: 1px solid rgba(245,158,11,.35); color: var(--yellow); }
.alert-error   { background: rgba(239,68,68,.12); border: 1px solid rgba(239,68,68,.3); color: var(--red); }

/* ── Typography ──────────────────────────────────────────────── */
.page-title { font-family: var(--font-display); font-size: 2.2rem; letter-spacing: .04em; color: var(--text); margin-bottom: .25rem; }
.page-subtitle { color: var(--text-muted); font-size: .9rem; margin-bottom: 1.75rem; }
h2 { font-family: var(--font-display); font-size: 1.5rem; letter-spacing: .04em; margin-bottom: 1rem; }
h3 { font-size: 1rem; font-weight: 600; color: var(--text); margin-bottom: .5rem; }

/* ── Cards ───────────────────────────────────────────────────── */
.card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1.5rem;
}
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; }
.card-title { font-family: var(--font-display); font-size: 1.25rem; letter-spacing: .04em; }

/* ── Grid layouts ────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.25rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.25rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.25rem; }
@media (max-width: 900px) { .grid-4, .grid-3 { grid-template-columns: repeat(2,1fr); } }
@media (max-width: 600px) { .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; } }

/* ── Stat blocks ─────────────────────────────────────────────── */
.stat-block {
  background: var(--bg-raised); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.25rem; text-align: center;
}
.stat-value { font-family: var(--font-display); font-size: 2.2rem; color: var(--accent); line-height: 1; }
.stat-label { font-size: .75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .08em; margin-top: .25rem; }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .55rem 1.2rem; border-radius: var(--radius); font-size: .875rem;
  font-weight: 600; cursor: pointer; transition: all .18s; border: none; font-family: var(--font-body);
  text-decoration: none;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn-primary { background: var(--accent); color: #000; }
.btn-primary:hover { background: #33eaff; box-shadow: 0 4px 16px rgba(0,229,255,0.3); }
.btn-secondary { background: var(--bg-raised); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-success { background: var(--green); color: #000; }
.btn-success:hover { background: #4ade80; }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #f87171; }
.btn-warning { background: var(--yellow); color: #000; }
.btn-sm { padding: .35rem .75rem; font-size: .8rem; }
.btn-icon { padding: .45rem; border-radius: var(--radius); background: var(--bg-raised); border: 1px solid var(--border); cursor: pointer; color: var(--text-muted); display: inline-flex; }

/* ── Tables ──────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
th { color: var(--text-muted); font-weight: 600; font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; padding: .6rem 1rem; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
td { padding: .7rem 1rem; border-bottom: 1px solid rgba(30,42,58,.5); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,.02); }

/* ── Forms ───────────────────────────────────────────────────── */
.form-group { margin-bottom: 1.1rem; }
.form-label { display: block; font-size: .8rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: .4rem; }
.form-control {
  width: 100%; padding: .6rem .9rem; background: var(--bg-raised); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text); font-size: .9rem; transition: border-color .2s;
}
.form-control:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0,229,255,.08); }
.form-control::placeholder { color: var(--text-dim); }

/* Calendar / date-picker icons: the native icon renders near-black on the dark
   theme and is almost invisible. We replace the default WebKit icon with our own
   light-grey SVG calendar glyph so it is clearly visible and clickable. Setting
   color-scheme:dark also makes Firefox/Chromium render light native controls. */
input[type="date"], input[type="datetime-local"], input[type="time"],
input[type="month"], input[type="week"] {
  color-scheme: dark;
}
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="datetime-local"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator,
input[type="month"]::-webkit-calendar-picker-indicator,
input[type="week"]::-webkit-calendar-picker-indicator {
  /* Custom light SVG glyph (calendar outline) — guaranteed visible on dark bg */
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23c3ccdd' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><rect x='3' y='4' width='18' height='18' rx='2' ry='2'></rect><line x1='16' y1='2' x2='16' y2='6'></line><line x1='8' y1='2' x2='8' y2='6'></line><line x1='3' y1='10' x2='21' y2='10'></line></svg>");
  background-repeat: no-repeat;
  background-position: center;
  opacity: .8;
  cursor: pointer;
  transition: opacity .15s;
}
input[type="date"]::-webkit-calendar-picker-indicator:hover,
input[type="datetime-local"]::-webkit-calendar-picker-indicator:hover,
input[type="time"]::-webkit-calendar-picker-indicator:hover,
input[type="month"]::-webkit-calendar-picker-indicator:hover,
input[type="week"]::-webkit-calendar-picker-indicator:hover {
  opacity: 1;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.validation-summary-errors ul { list-style: none; }
.validation-summary-errors li, .field-validation-error { color: var(--red); font-size: .8rem; margin-top: .3rem; }

/* ── Position badges ─────────────────────────────────────────── */
.pos-badge { display: inline-block; font-family: var(--font-display); font-size: .75rem; letter-spacing: .08em; padding: .15rem .55rem; border-radius: 4px; font-weight: 400; }
.pos-gk  { background: rgba(245,158,11,.15); color: var(--gk-color); border: 1px solid rgba(245,158,11,.3); }
.pos-def { background: rgba(34,197,94,.15);  color: var(--def-color); border: 1px solid rgba(34,197,94,.3); }
.pos-mid { background: rgba(59,130,246,.15); color: var(--mid-color); border: 1px solid rgba(59,130,246,.3); }
.pos-str { background: rgba(239,68,68,.15);  color: var(--str-color); border: 1px solid rgba(239,68,68,.3); }

/* ── Status badges ───────────────────────────────────────────── */
.badge { display: inline-block; font-size: .72rem; font-weight: 600; padding: .2rem .55rem; border-radius: 20px; text-transform: uppercase; letter-spacing: .04em; }
.badge-open     { background: rgba(34,197,94,.15);  color: var(--green);  border: 1px solid rgba(34,197,94,.3); }
.badge-upcoming { background: rgba(245,158,11,.15); color: var(--yellow); border: 1px solid rgba(245,158,11,.3); }
.badge-closed   { background: rgba(107,122,148,.15); color: var(--text-muted); border: 1px solid var(--border); }
.badge-processed{ background: rgba(124,58,237,.15); color: #a78bfa; border: 1px solid rgba(124,58,237,.3); }

/* ── Auth pages ──────────────────────────────────────────────── */
.auth-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 2.5rem; box-shadow: var(--shadow); }
.auth-logo { text-align: center; margin-bottom: 2rem; }
.auth-logo .brand-text { font-size: 2rem; }
.auth-title { font-family: var(--font-display); font-size: 1.6rem; text-align: center; margin-bottom: .5rem; letter-spacing: .04em; }
.auth-sub { color: var(--text-muted); text-align: center; font-size: .875rem; margin-bottom: 1.75rem; }

/* ── Dashboard ───────────────────────────────────────────────── */
.dashboard-hero {
  background: linear-gradient(135deg, var(--bg-card), var(--bg-raised));
  border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 2rem;
  margin-bottom: 1.5rem; position: relative; overflow: hidden;
}
.dashboard-hero::before {
  content: '⚽'; position: absolute; right: 1.5rem; top: 50%; transform: translateY(-50%) rotate(-15deg);
  font-size: 5rem; opacity: .07; pointer-events: none;
}
.hero-rank { font-family: var(--font-display); font-size: 4rem; color: var(--accent); line-height: 1; }
.hero-pts  { font-family: var(--font-display); font-size: 1.5rem; color: var(--text-muted); }

/* ── Player cards ────────────────────────────────────────────── */
.player-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 1rem; transition: all .2s; cursor: pointer;
}
.player-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--glow); }
.player-photo { width: 60px; height: 75px; object-fit: cover; border-radius: 6px; background: var(--bg-raised); }
.player-name { font-weight: 600; font-size: .9rem; margin-top: .5rem; }
.player-team { font-size: .78rem; color: var(--text-muted); }
.player-pts  { font-family: var(--font-display); font-size: 1.6rem; color: var(--accent); }

/* ── Leaderboard ─────────────────────────────────────────────── */
.lb-row { display: flex; align-items: center; gap: .75rem; padding: .4rem 1rem; border-bottom: 1px solid rgba(30,42,58,.5); }
.lb-rank { font-family: var(--font-display); font-size: 1.15rem; color: var(--text-dim); width: 24px; flex-shrink: 0; text-align: left; }
.lb-rank.top1 { color: #fbbf24; }
.lb-rank.top2 { color: #94a3b8; }
.lb-rank.top3 { color: #b45309; }
.lb-name { flex: 1; font-weight: 500; }
.lb-pts  { font-family: var(--font-display); font-size: 1.1rem; color: var(--accent); }
.lb-budget { font-size: .8rem; color: var(--text-muted); }

/* ── Player grid for bids ────────────────────────────────────── */
.bid-player-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.bid-player-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 1.25rem; display: flex; flex-direction: column; gap: .75rem;
}
.bid-player-card.has-bid { border-color: rgba(0,229,255,.35); }
.bid-amount-input { display: flex; gap: .5rem; }
.bid-amount-input .form-control { flex: 1; }

/* ── Score entry table ───────────────────────────────────────── */
.score-checkbox { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }
.score-num { width: 60px; padding: .35rem .5rem; text-align: center; background: var(--bg-raised); border: 1px solid var(--border); border-radius: 4px; color: var(--text); font-size: .85rem; }
.score-num:focus { outline: none; border-color: var(--accent); }

/* ── Pagination ──────────────────────────────────────────────── */
.pagination { display: flex; gap: .4rem; justify-content: center; margin-top: 1.5rem; }
.page-btn { padding: .4rem .85rem; border-radius: var(--radius); background: var(--bg-raised); border: 1px solid var(--border); color: var(--text-muted); font-size: .85rem; cursor: pointer; text-decoration: none; transition: all .15s; }
.page-btn:hover, .page-btn.active { border-color: var(--accent); color: var(--accent); text-decoration: none; }

/* ── Misc ────────────────────────────────────────────────────── */
.text-accent { color: var(--accent); }
.text-muted  { color: var(--text-muted); }
.text-green  { color: var(--green); }
.text-red    { color: var(--red); }
.text-yellow { color: var(--yellow); }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-gap { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.divider { border: none; border-top: 1px solid var(--border); margin: 1.5rem 0; }
.empty-state { text-align: center; color: var(--text-muted); padding: 3rem 1rem; }
.empty-state .icon { font-size: 2.5rem; margin-bottom: .75rem; }
.currency { font-family: var(--font-display); }

/* ── Scrollbar ───────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border-glow); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ══════════════════════════════════════════════════════════════════════
   MOBILE LAYOUT  (≤ 767px)
   Phones only. Tablets (768px+) deliberately keep the full desktop layout,
   so nothing below this breakpoint affects an iPad or a desktop browser.
   ══════════════════════════════════════════════════════════════════════ */

/* Hamburger + backdrop are desktop-hidden; the media query switches them on. */
.nav-toggle {
  display: none; background: transparent; border: 1px solid var(--border);
  color: var(--text); border-radius: var(--radius); cursor: pointer;
  width: 40px; height: 40px; align-items: center; justify-content: center;
  font-size: 1.1rem; flex-shrink: 0; padding: 0;
}
.nav-backdrop { display: none; }

@media (max-width: 767px) {

  /* ── Navigation: slide-out drawer ──────────────────────────────────
     The horizontal nav overflowed off-screen, so menu items could only be
     reached by scrolling the page sideways. Same markup, re-presented as a
     drawer — no duplicated link list to keep in sync. */
  .navbar {
    padding: 0 .75rem; gap: .6rem; height: 56px;
    /* backdrop-filter makes an element the CONTAINING BLOCK for position:fixed
       descendants, so the drawer was being sized against the 56px navbar instead of
       the viewport — it opened as an invisible sliver. */
    backdrop-filter: none; -webkit-backdrop-filter: none;
    /* sticky + z-index creates a stacking context the drawer can't escape, so it was
       painting UNDERNEATH the backdrop (150). Lift the whole bar above it. */
    z-index: 300;
  }
  .nav-toggle { display: flex; }
  .brand-text { font-size: 1.05rem; }

  .navbar-nav {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: 82vw; max-width: 320px;
    flex-direction: column; gap: 0;
    background: #0d1420; border-right: 1px solid var(--border);
    padding: 4.5rem 0 1.5rem; margin: 0;
    overflow-y: auto; -webkit-overflow-scrolling: touch;
    transform: translateX(-100%);
    transition: transform .25s ease;
    z-index: 200;
  }
  body.nav-open .navbar-nav { transform: translateX(0); }

  .navbar-nav li { width: 100%; }
  .nav-link {
    display: block; width: 100%;
    padding: .95rem 1.4rem; border-radius: 0;
    font-size: .95rem; border-left: 3px solid transparent;
  }
  .nav-link.active { border-left-color: var(--accent); background: var(--bg-raised); }

  .nav-backdrop {
    position: fixed; inset: 0; background: rgba(0,0,0,.55);
    z-index: 150; border: 0; padding: 0;
  }
  body.nav-open { overflow: hidden; }
  body.nav-open .nav-backdrop { display: block; }

  /* The signed-in email eats the whole bar on a phone — keep Sign Out only. */
  .navbar-user { margin-left: auto; gap: .4rem; }
  .navbar-user > a { display: none; }

  /* ── Content & grids ───────────────────────────────────────────────── */
  .main-content { padding: 1rem .7rem; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .card { padding: .9rem; }
  .page-title { font-size: 1.35rem; }
  .page-subtitle { font-size: .82rem; }

  /* ── Side-by-side panels stack ─────────────────────────────────────
     The auction page put a fixed 290px "My Team" panel beside a flexible
     table; the table shrank to a sliver instead of wrapping. */
  .split-layout { flex-direction: column !important; }
  .split-side {
    width: 100% !important; position: static !important;
    flex-shrink: 1 !important; order: -1;   /* squad summary first on a phone */
  }

  /* ── Tables ────────────────────────────────────────────────────────
     Secondary columns are hidden and surfaced by tapping a row instead. */
  .col-secondary { display: none !important; }
  /* !important because these cards carry an inline overflow:hidden, which would
     otherwise clip the scrollable table instead of letting it pan. */
  .table-scroll { overflow-x: auto !important; -webkit-overflow-scrolling: touch; }
  .table-scroll table { min-width: 100%; }
  table { font-size: .84rem; }

  .row-detail-toggle { cursor: pointer; }
  .row-detail { display: none; }
  .row-detail.open { display: table-row; }
  .row-detail td {
    padding: .5rem .75rem .75rem; font-size: .78rem;
    color: var(--text-muted); background: rgba(255,255,255,.02);
  }

  /* ── Touch targets & iOS behaviour ─────────────────────────────────
     16px inputs stop iOS Safari zooming in when a field is focused, which
     otherwise throws the whole page off every time you type a bid. */
  .btn, .btn-sm { min-height: 40px; }
  input, select, textarea { font-size: 16px !important; }
  .btn-sm { padding: .4rem .7rem; }

  /* Reorder arrows replace drag-and-drop, which doesn't work on touch. */
  .reorder-btns { display: inline-flex !important; }
}

/* Drag handles are meaningless without a mouse; arrows are always available
   but only take over visually on touch devices. */
@media (hover: none) and (pointer: coarse) {
  .drag-hint { display: none; }
}

/* Compact per-row meta line: only shown where the stat columns are hidden. */
.mobile-only-meta { display: none; }
@media (max-width: 767px) { .mobile-only-meta { display: block; } }
