/* ===========================================================================
   EuroJackpot Stats — classic clean look.
   Blue header bars (#3b6fe0), dark sidebar, white/yellow ball circles,
   alternating light-blue / white table rows. Plenty of whitespace.
   =========================================================================== */

:root {
  --blue:        #3b6fe0;
  --blue-dark:   #2d59bd;
  /* Highlight accent: ~25% deeper & more saturated than --blue, so highlighted
     main balls stand out by COLOR (not size). */
  --blue-hi:      #1f49c9;
  --blue-hi-dark: #15349a;
  /* Euro highlight ring: a BRIGHTER azure blue that pops against the near-black
     euro ball, and a distinctly lighter shade than --blue-hi so the main and
     euro highlights stay visually distinguishable when both are active. */
  --euro-hi:      #3b82f6;
  --euro-ball:    #1f2430;   /* euro ball fill */
  --euro-ink:     #f5c518;   /* euro ball number */
  --blue-light:  #eaf1ff;   /* alternating row tint */
  --sidebar-bg:  #1f2733;
  --sidebar-bg2: #283242;
  --sidebar-fg:  #c7d0dc;
  --sidebar-active: #3b6fe0;
  --ink:         #233044;
  --muted:       #6b7787;
  --border:      #e2e7ef;
  --yellow:      #ffd400;
  --bg:          #f4f6fa;
  --card:        #ffffff;
  --shadow:      0 1px 3px rgba(20,40,80,.08), 0 4px 14px rgba(20,40,80,.05);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  display: flex;
  min-height: 100vh;
}

/* Safety net: never show number-input spinner arrows anywhere in the app.
   The drawn-number "balls" are display-only spans, but this guards against any
   numeric <input> (e.g. the delay-threshold field) sprouting steppers too. */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number] { -moz-appearance: textfield; appearance: textfield; }

/* ---------------- Sidebar ---------------- */
.sidebar {
  width: 240px;
  flex: 0 0 240px;
  background: var(--sidebar-bg);
  color: var(--sidebar-fg);
  display: flex;
  flex-direction: column;
  transition: width .18s ease, flex-basis .18s ease;
}
.sidebar.collapsed { width: 56px; flex-basis: 56px; }
.sidebar.collapsed .brand-text,
.sidebar.collapsed .nav-section-title,
.sidebar.collapsed .nav-item span,
.sidebar.collapsed .sidebar-footer { display: none; }

.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 16px; font-weight: 700; font-size: 18px; color: #fff;
  background: var(--sidebar-bg2);
}
.brand-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--yellow); flex: 0 0 auto; }
.sidebar-toggle {
  margin-left: auto; background: transparent; border: 0; color: var(--sidebar-fg);
  font-size: 18px; cursor: pointer;
}
.nav { flex: 1; overflow-y: auto; padding: 8px 0; }
.nav-section-title {
  padding: 14px 18px 6px; font-size: 11px; letter-spacing: .08em;
  text-transform: uppercase; color: #7e8a9b;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 18px; cursor: pointer; color: var(--sidebar-fg);
  border-left: 3px solid transparent; font-size: 14px; user-select: none;
}
.nav-item:hover { background: var(--sidebar-bg2); color: #fff; }
.nav-item.active { background: var(--sidebar-bg2); color: #fff; border-left-color: var(--sidebar-active); }
.nav-item .ico { width: 18px; text-align: center; opacity: .8; }
.sidebar-footer { padding: 12px 18px; font-size: 11px; color: #66728a; }

/* ---------------- Content / topbar ---------------- */
.content { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 56px; flex-shrink: 0;   /* never squeezed by the tall .main column */
  background: var(--blue); color: #fff;
  display: flex; align-items: center; gap: 16px; padding: 0 20px;
  box-shadow: var(--shadow);
}
.topbar-title { font-size: 18px; font-weight: 600; margin: 0; }
.mobile-menu { display: none; background: transparent; border: 0; color: #fff; font-size: 20px; cursor: pointer; }
.lang-toggle { margin-left: auto; display: flex; gap: 4px; }
.lang-toggle button {
  background: rgba(255,255,255,.15); color: #fff; border: 0; border-radius: 5px;
  padding: 5px 10px; font-size: 12px; font-weight: 600; cursor: pointer;
}
.lang-toggle button.active { background: #fff; color: var(--blue); }

.main { padding: 22px; overflow-y: auto; }
.view { max-width: 1100px; margin: 0 auto; }

/* ---------------- Cards / sections ---------------- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); margin-bottom: 20px; }
.card-head { background: var(--blue); color: #fff; padding: 11px 16px; font-weight: 600; border-radius: 10px 10px 0 0; font-size: 15px; }
.card-body { padding: 16px; }
.section-bar { background: var(--blue); color:#fff; padding: 10px 16px; border-radius: 8px; font-weight: 600; margin: 0 0 14px; }

.row { display: flex; gap: 20px; flex-wrap: wrap; }
.col { flex: 1; min-width: 280px; }

/* ---------------- Year selector + grid ---------------- */
.year-display { font-size: 64px; font-weight: 800; color: var(--blue); line-height: 1; letter-spacing: -2px; }
.year-controls { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.year-controls select {
  font-size: 15px; padding: 8px 12px; border: 1px solid var(--border);
  border-radius: 8px; background: #fff; color: var(--ink);
}
.grid-filters { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0; }
.grid-filters button {
  border: 1px solid var(--border); background: #fff; color: var(--ink);
  border-radius: 6px; padding: 6px 12px; font-size: 13px; cursor: pointer;
}
.grid-filters button:hover { background: var(--blue-light); border-color: var(--blue); }
.grid-filters button.active { background: var(--blue); color: #fff; border-color: var(--blue-dark); }
.grid-filters button:disabled { cursor: default; }

/* Archive-table ROW filter controls (above the table) */
.rf-controls { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
.rf-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.rf-row > strong { color: var(--ink); }
.rf-count { margin-left: auto; font-weight: 600; }

/* Second row: combined parity × range filters — visually grouped, tinted. */
.grid-filters-combined { margin-top: -4px; padding-top: 10px; border-top: 1px dashed var(--border); }
.grid-filters-combined button { background: var(--blue-light); border-color: #c7d6f7; color: var(--blue-dark); font-weight: 600; }
.grid-filters-combined button:hover { background: #dbe6ff; }

/* "Number line" text input, two-way synced with the 1–50 grid. */
.num-line { max-width: 560px; margin: 0 0 12px; }
.num-line-input {
  width: 100%; box-sizing: border-box; border: 1px solid var(--border);
  border-radius: 6px; padding: 8px 12px; font-size: 15px; color: var(--ink);
  font-variant-numeric: tabular-nums; letter-spacing: .04em;
}
.num-line-input:focus { outline: none; border-color: var(--blue); }
.num-line-input::placeholder { color: var(--muted); letter-spacing: normal; }

.num-grid { display: grid; grid-template-columns: repeat(10, 1fr); gap: 6px; max-width: 560px; }
/* Euro selector grid (1–12): compact, 6 per row × 2 rows. */
.num-grid.euro-grid { grid-template-columns: repeat(6, 1fr); max-width: 340px; }
.num-cell {
  aspect-ratio: 1 / 1; display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: 50%; font-size: 13px; cursor: pointer;
  background: #fff; color: var(--ink); user-select: none; transition: all .08s;
}
.num-cell:hover { border-color: var(--blue); }
.num-cell.selected { background: var(--blue); color: #fff; border-color: var(--blue-dark); font-weight: 700; }

/* ---------------- Balls ---------------- */
.balls { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.ball {
  width: 34px; height: 34px; border-radius: 50%; display: inline-flex;
  align-items: center; justify-content: center; font-weight: 700; font-size: 14px;
  flex: 0 0 auto;
  /* Display-only text. overflow:visible guarantees a ball can NEVER become a
     scroll box (a stray overflow rule once gave main balls scrollbar arrows
     that looked like number-input steppers). */
  overflow: visible;
  /* Smooth COLOUR change when a highlight toggles (no size/layout change). */
  transition: background-color 0.12s ease, border-color 0.12s ease,
              box-shadow 0.12s ease, opacity 0.12s ease;
}
/* main numbers = white circle, thin border.
   Class is `ball-main` (not `main`) to avoid colliding with the `.main`
   content-scroll-container rule. */
.ball-main { background: #fff; color: var(--ink); border: 1.5px solid #c4ccda; }
/* Grid-selection highlight (.hit): intensified deep-blue ring (~25% stronger). */
.ball-main.hit { border-color: var(--blue-hi); box-shadow: 0 0 0 2.5px var(--blue-hi); background: var(--blue-light); }
/* euro numbers = dark circle with yellow text (the classic look). Same .ball
   size/shape — only the colours differ from .ball-main. */
.ball-euro { background: var(--euro-ball); color: var(--euro-ink); border: 1.5px solid var(--euro-ball); }

/* Ball-highlight control (archive table): matching MAIN balls pop in the
   intensified deep blue (--blue-hi, ~25% stronger than --blue), non-matching
   ones are dimmed. SAME SIZE as normal balls — highlight is by colour only.
   Declared AFTER .ball-main(.hit) so equal specificity favours the highlight. */
.ball-main.ball-hi { background: var(--blue-hi); color: #fff; border-color: var(--blue-hi-dark); border-width: 2px; }
.ball-main.ball-dim { opacity: 0.3; border-color: #eef1f6; }

/* EURO highlight — same mechanism (.ball-hi / .ball-dim), shown as a bright
   azure RING around the dark ball (the ball keeps its dark/yellow look). A thin
   white gap between ball and ring keeps the ring readable against the dark
   fill; --euro-hi stays lighter than the main --blue-hi so main vs euro
   highlights remain distinguishable when both are on. */
.ball-euro.ball-hi { border-color: var(--euro-hi); box-shadow: 0 0 0 2px #fff, 0 0 0 4.5px var(--euro-hi); }
.ball-euro.ball-dim { opacity: 0.3; }

.ball.sep { width: 8px; }

/* big balls for header cards */
.ball.big { width: 44px; height: 44px; font-size: 17px; }

/* ---------------- Header draw cards ---------------- */
.draw-card .draw-date { font-size: 14px; color: var(--muted); margin-bottom: 10px; }
.draw-card .draw-weekday { font-weight: 600; color: var(--ink); }

/* ---------------- Tables ---------------- */
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data thead th {
  background: var(--blue); color: #fff; text-align: left; padding: 10px 12px;
  font-weight: 600; position: sticky; top: 0;
  z-index: 2;   /* above dimmed balls (opacity creates their own stacking context) */
}
table.data tbody td { padding: 8px 12px; border-bottom: 1px solid var(--border); }
table.data tbody tr:nth-child(odd)  { background: #fff; }
table.data tbody tr:nth-child(even) { background: var(--blue-light); }
table.data tbody tr:hover { background: #dde8ff; }
.clickable { color: var(--blue); cursor: pointer; text-decoration: none; font-weight: 600; }
.clickable:hover { text-decoration: underline; }
.num-tag { display:inline-block; min-width: 26px; text-align:center; }

/* sortable header hint */
th.sortable { cursor: pointer; }
th.sortable::after { content: " ⇅"; opacity: .55; font-size: 11px; }

/* ---------------- Charts ---------------- */
.chart-wrap { position: relative; height: 320px; }
.chart-wrap.tall { height: 420px; }

/* ---------------- Misc ---------------- */
.muted { color: var(--muted); }
.pill { display:inline-block; padding: 2px 9px; border-radius: 999px; background: var(--blue-light); color: var(--blue-dark); font-size: 12px; font-weight: 600; }
.disclaimer {
  background: #fff8e1; border: 1px solid #ffe08a; color: #6b5300;
  padding: 14px 16px; border-radius: 8px; margin-bottom: 18px; font-size: 14px; line-height: 1.5;
}
.disclaimer strong { color: #8a6d00; }
.empty-state { text-align: center; padding: 60px 20px; color: var(--muted); }
.kpi-row { display: flex; gap: 16px; flex-wrap: wrap; }
.kpi { background: var(--card); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); padding: 16px 18px; flex: 1; min-width: 150px; }
.kpi .kpi-val { font-size: 28px; font-weight: 800; color: var(--blue); }
.kpi .kpi-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.controls-bar { display:flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.controls-bar input[type="number"] { width: 90px; padding: 7px 10px; border:1px solid var(--border); border-radius: 6px; }
.controls-bar select { padding: 7px 10px; border:1px solid var(--border); border-radius: 6px; background:#fff; }
.btn { background: var(--blue); color:#fff; border:0; border-radius: 6px; padding: 8px 16px; font-weight:600; cursor:pointer; }
.btn:hover { background: var(--blue-dark); }

/* ---------------- Modal ---------------- */
.modal { position: fixed; inset: 0; background: rgba(15,25,45,.45); display:flex; align-items:center; justify-content:center; z-index: 50; }
.modal.hidden { display: none; }
.modal-card { background:#fff; border-radius: 12px; padding: 24px; min-width: 320px; max-width: 90vw; box-shadow: 0 20px 60px rgba(0,0,0,.3); position: relative; }
.modal-close { position:absolute; top: 10px; right: 14px; border:0; background:transparent; font-size: 26px; cursor:pointer; color: var(--muted); }

/* ---------------- Responsive ---------------- */
@media (max-width: 760px) {
  .sidebar { position: fixed; z-index: 40; height: 100%; transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .mobile-menu { display: inline-block; }
  .num-grid { grid-template-columns: repeat(8, 1fr); }
}

/* ---------------- Auth gate (login screen) ---------------- */
/* booting: nothing visible until the session check finishes.
   signed-out: only the login card; the app shell stays hidden. */
body.booting .sidebar, body.booting .content, body.booting .auth-screen { display: none; }
body:not(.signed-out) .auth-screen { display: none; }
body.signed-out .sidebar, body.signed-out .content { display: none; }
.auth-screen { flex: 1; display: flex; align-items: center; justify-content: center; padding: 24px 16px; min-height: 100vh; }
.auth-card { width: 100%; max-width: 380px; margin: 0; }
.auth-head { display: flex; align-items: center; gap: 10px; font-size: 17px; }
.auth-title { margin: 0 0 14px; font-size: 18px; color: var(--ink); }
.auth-form { display: flex; flex-direction: column; gap: 6px; }
.auth-form label { font-size: 13px; font-weight: 600; color: var(--ink); margin-top: 6px; }
.auth-form input {
  padding: 9px 10px; font-size: 15px; border: 1px solid var(--border);
  border-radius: 6px; background: #fff; color: var(--ink);
}
.auth-form input:focus { outline: none; border-color: var(--blue); }
.auth-form .btn { margin-top: 12px; padding: 10px 16px; font-size: 15px; }
.btn:disabled { opacity: .6; cursor: default; }
.hidden { display: none; }

.logout-btn {
  background: rgba(255,255,255,.15); color: #fff; border: 1px solid rgba(255,255,255,.35);
  border-radius: 5px; padding: 5px 10px; font-size: 12px; font-weight: 600; cursor: pointer;
}
.logout-btn:hover { background: rgba(255,255,255,.28); }

/* ---------------- Data entry ("Přidat losování") ---------------- */
.admin-card { max-width: 640px; }
.admin-banner { padding: 12px 16px; border-radius: 8px; margin-bottom: 18px; font-weight: 600; }
.admin-banner.ok  { background: #e6f6ec; color: #1b7a3d; border: 1px solid #b7e3c4; }
.admin-banner.err { background: #fdecec; color: #b3261e; border: 1px solid #f4c0bd; }
.admin-banner.hidden { display: none; }
.admin-field { margin-bottom: 16px; }
.admin-field > label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 14px; }
.admin-field .hint { color: var(--muted); font-weight: 400; font-size: 12px; }
.admin-row { display: flex; gap: 8px; flex-wrap: wrap; }
.admin-num {
  width: 56px; text-align: center; padding: 9px 6px; font-size: 16px;
  border: 1px solid var(--border); border-radius: 6px; background: #fff; color: var(--ink);
}
.admin-num:focus { outline: none; border-color: var(--blue); }
.admin-num.euro { border-color: #11161f; }
.admin-field input[type=date] {
  padding: 9px 10px; font-size: 15px; border: 1px solid var(--border);
  border-radius: 6px; background: #fff; color: var(--ink);
}
.admin-field input[type=date]:focus { outline: none; border-color: var(--blue); }
.admin-actions { margin-top: 8px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.csv-file { margin: 4px 0 16px; font-size: 14px; max-width: 100%; }
.csv-kpis { margin-bottom: 12px; }
.csv-rejections { margin: 6px 0 14px; padding-left: 20px; font-size: 13px; color: #b3261e; }
.csv-progress { font-variant-numeric: tabular-nums; }

/* Detail modal: delete action */
.modal-actions { margin-top: 18px; display: flex; justify-content: flex-end; }
.btn-danger { background: #c62828; }
.btn-danger:hover { background: #a31f1f; }

/* ---------------- Archive: two-column layout + sticky control panel -------- */
/* The archive view may use more width than the other views. */
.view:has(.archive-layout) { max-width: 1500px; }

/* The breakpoint is measured on the space actually available to the archive
   (container query), so the table never overflows next to the sidebar.
   Narrow: one column, control panel first (collapsible), table below. */
.archive-layout { container-type: inline-size; }
.archive-grid { display: flex; flex-direction: column; }
.archive-main { min-width: 0; }
.archive-main .col { min-width: min(400px, 100%); }   /* 7 big balls fit on one line */
.archive-table-wrap { overflow-x: auto; }

.archive-panel {
  margin-bottom: 20px;
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow); padding: 10px;
}
.archive-panel-toggle {
  display: block; width: 100%; text-align: left; cursor: pointer;
  background: var(--blue); color: #fff; border: 0; border-radius: 6px;
  padding: 8px 12px; font-size: 14px; font-weight: 600;
}
.archive-panel-body { margin-top: 10px; }
.archive-panel-body.collapsed { display: none; }

/* Panel sections: compact cards with small blue section titles. */
.archive-panel .card { border: 0; box-shadow: none; border-radius: 8px; margin-bottom: 10px; }
.archive-panel-table-controls .card:last-child { margin-bottom: 0; }
.archive-panel .card-head { font-size: 12.5px; padding: 6px 10px; border-radius: 6px; }
.archive-panel .card-body { padding: 8px 2px 0; }
.archive-panel .grid-filters { gap: 5px; margin: 0 0 6px; }
.archive-panel .grid-filters button { padding: 4px 8px; font-size: 12px; }
.archive-panel .grid-filters label { font-size: 12px; align-self: center; }
.archive-panel .grid-filters-combined { margin-top: 0; padding-top: 6px; }
.archive-panel .num-line { max-width: none; margin: 0 0 8px; }
.archive-panel .num-line-input { padding: 6px 10px; font-size: 14px; }
.archive-panel .num-grid { grid-template-columns: repeat(10, minmax(0, 34px)); gap: 5px; max-width: none; }
.archive-panel .num-grid.euro-grid { grid-template-columns: repeat(6, minmax(0, 34px)); }
.archive-panel .num-cell { font-size: 12px; }
.archive-panel .rf-controls { gap: 0; margin: 0; }
.archive-panel .rf-row { gap: 8px; }
.archive-panel .rf-row > strong { font-size: 12px; }
.archive-panel .rf-count { margin: 0 0 6px auto; font-size: 12px; }

/* "Hledat čísla": label + search line per row, clear button below. */
.archive-panel .search-card { margin: 10px 0 0; }
.archive-panel .search-row { display: grid; grid-template-columns: 96px minmax(0, 1fr); align-items: center; gap: 8px; margin-bottom: 6px; }
.archive-panel .search-row label { font-size: 12px; font-weight: 600; color: var(--ink); }
.archive-panel .search-actions { justify-content: flex-end; margin-bottom: 0; }

/* Archive balls are clickable (toggle the number in the selection). Hover is a
   small scale-up so it never fights the highlight rings (box-shadow). */
.archive-main .ball:not(.sep) { cursor: pointer; }
.archive-main .ball:not(.sep):hover { transform: scale(1.1); }
.archive-main .ball {
  transition: background-color 0.12s ease, border-color 0.12s ease,
              box-shadow 0.12s ease, opacity 0.12s ease, transform 0.08s ease;
}

/* Wide: panel left (sticky in the .main scroll area, scrolls internally only
   if taller than the viewport), table right (scrolls with the page). */
@container (min-width: 940px) {
  .archive-grid {
    display: grid; grid-template-columns: 440px minmax(0, 1fr);
    gap: 18px; align-items: start;
  }
  .archive-panel {
    margin-bottom: 0;
    position: sticky; top: 0;
    max-height: calc(100vh - 56px - 44px);   /* topbar + .main padding */
    overflow-y: auto;
  }
  .archive-panel-toggle { display: none; }
  .archive-panel-body { margin-top: 0; }
  .archive-panel-body.collapsed { display: block; }
  /* No horizontal scroll box here, so the table header can stick to the page.
     Sticky offsets count from the inside of .main's 22px padding: -22px pins
     the header row flush under the app bar, so no rows peek out above it. */
  .archive-table-wrap { overflow: visible; }
  .archive-main table.data thead th { top: -22px; }
}

@media (max-width: 760px) {
  .archive-panel .num-grid { grid-template-columns: repeat(8, minmax(0, 1fr)); }
  .archive-panel .num-grid.euro-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); max-width: 260px; }
}
