/* =====================================================
   Base
===================================================== */
html {
  -webkit-text-size-adjust: 100%;
  scrollbar-width: none; /* Firefox */
}

body {
  background-color: #0a0a23;
  color: #ffffff;
  font-family: Arial, sans-serif;
  margin: 0;
  overflow: auto; /* omogoči scroll */
}

/* Chrome, Edge, Safari */
::-webkit-scrollbar {
  display: none;
}

/* =====================================================
   Header (fixed)
===================================================== */
.main-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  background-color: #1a1d38;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 2rem;
  z-index: 999;
  box-shadow: 0 4px 8px rgba(0,0,0,0.6);
}

.header-left {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
}

.header-right {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
}

.logo {
  height: 40px;
  margin-right: 1rem;
}

h1#event-title {
  font-size: 1.6rem;
  margin: 0;
  color: #ffffff;
  text-align: center;
}

/* =====================================================
   Container (space only for fixed header)
===================================================== */
.container {
  padding: 64px 2rem 2rem; /* prostor za fixed header */
  max-width: 1400px;
  margin: 0 auto;
}

/* =====================================================
   Top row under header (SCROLLS with content)
   Date left + Search/Buttons right
===================================================== */
.top-controls {
  position: static; /* ključ: NI fixed */
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0 0;
  margin: 0;
}

#day-header {
  pointer-events: none;
  display: flex;
  align-items: center;
  min-height: 44px;
}

#day-header .day-divider {
  background: transparent !important;
  border: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  padding: 0 !important;
  margin: 0 !important;
  display: flex;
  align-items: center;
}

#day-header .day-divider-top {
  display: none !important; /* ni DAY 1 */
}

/* =====================================================
   ✅ UNIFIED DATE STYLE (TOP + Past/Next day dividers)
   - ohrani EXACT look kot imaš zdaj (1.4rem, 800, 0.95, translateY(1px))
   - uporabi za vse .day-divider-date kjerkoli na strani
===================================================== */
.day-divider .day-divider-date,
#day-header .day-divider-date {
  font-size: 1.4rem;
  font-weight: 800;
  opacity: 0.95;
  white-space: nowrap;
  transform: translateY(1px);
}

/* če se kje pojavi “DAY 1 …” tudi v listi, ga skrij */
.day-divider .day-divider-top {
  display: none !important;
}

/* right side group */
.controls-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

/* Search */
.search-wrapper {
  position: relative;
}

.startlist-search {
  width: 260px;
  max-width: 70vw;
  padding: 10px 12px;
  padding-right: 36px; /* prostor za ✕ */
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.25);
  background: rgba(0,0,0,0.25);
  color: #fff;
  outline: none;
  font-size: 16px;
  box-sizing: border-box;
}

.startlist-search::placeholder {
  opacity: 0.7;
}

.clear-search {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: rgba(255,255,255,0.6);
  font-size: 16px;
  cursor: pointer;
  padding: 0;
  display: none; /* pokažemo samo ko je text */
}

.clear-search:hover {
  color: #fff;
}

/* Buttons */
.top-buttons {
  display: flex;
  gap: 10px;
}

.top-btn {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.25);
  background: rgba(0,0,0,0.25);
  color: #fff;
  cursor: pointer;
  box-sizing: border-box;
}

.top-btn:hover {
  border-color: rgba(255,255,255,0.45);
}

/* Hide controls (toggle with keyboard) */
body.hide-controls .top-controls {
  display: none !important;
}

/* Past mode active button */
#toggle-past.past-active {
  background-color: #a6d6f9;
  color: #000000;
  border-color: #ffffff;
  font-weight: 600;
}

#toggle-past.past-active:hover {
  background-color: #a6d6f9;
}

/* =====================================================
   Labels / Category
===================================================== */
.section-label {
  font-size: 1.1rem;
  color: #aaa;
  margin-top: 1rem;
  margin-bottom: 0.5rem;
}

.category-label {
  background-color: #a6d6f9;
  color: #000000;
  padding: 0.8rem 1rem;
  border-radius: 6px;
  font-size: 1.3rem;
  font-weight: bold;
  margin-top: 2rem;
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  box-shadow: inset 0 0 0 2px #444;
}

/* =====================================================
   Entries
===================================================== */
.startlist-entry {
  display: flex;
  align-items: center;
  padding: 1rem;
  margin: 0.3rem 0;
  border-radius: 12px;
  font-size: 1.25rem;
  background-color: #1c1f33;
  box-shadow: 0 2px 4px rgba(0,0,0,0.4);
  transition: background-color 0.2s ease;
}

.startlist-entry:hover {
  background-color: #2a2e45;
}

.startlist-entry img.flag {
  width: 36px;
  height: 24px;
  object-fit: contain;
  margin-left: 0.8rem;
  margin-right: 0.2rem;
}

.startlist-entry .inline {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.startlist-entry .clubname {
  font-size: 1.05rem;
  font-style: italic;
  color: #ccc;
  margin-left: 0.5rem;
}

.results-marker {
  background-color: #5c2d91;
  text-align: center;
  font-weight: bold;
  justify-content: center;
}

#countdown-timer {
  font-size: 1.3rem;
  font-weight: bold;
  color: #00ff00;
  display: inline-block;
  min-width: 4.2ch;
  text-align: right;
}

#countdown-timer.expired {
  color: #ff5555;
}

/* Desktop “columns” */
.inline {
  display: flex;
  align-items: center;
}

.inline span:first-child {
  width: 60px;
  text-align: right; /* time */
}

.inline span:nth-child(2) {
  width: 50px;
  text-align: center;
  margin-left: 0.8rem; /* start number */
}

.inline span:nth-child(4) {
  margin-left: 0.5rem;
  font-weight: normal; /* team */
}

.section-label + .category-label {
  margin-top: 0.4rem;
}

/* =====================================================
   Desktop spacing fix (tighter time ↔ number)
===================================================== */
@media (min-width: 769px) {
  .startlist-entry .inline {
    gap: 0.6rem;
  }

  .startlist-entry .inline > #countdown-timer,
  .startlist-entry .inline > span:first-child {
    width: 58px;
    text-align: right;
  }

  .startlist-entry .inline .start-number,
  .startlist-entry .inline > span:nth-child(2) {
    width: 40px;
    margin-left: 0.25rem;
    text-align: right;
  }
}

/* =====================================================
   Mobile layout
===================================================== */
@media (max-width: 768px) {
  /* ✅ prostor za fixed header + banner (da nič ni skrito) */
  .container {
    padding: 78px 1rem 1.2rem;
  }

  h1#event-title {
    font-size: clamp(1.1rem, 5vw, 1.4rem);
  }

  .category-label {
    font-size: 1.0rem;
    padding: 0.6rem 0.7rem;
  }

  /* top row -> column layout on mobile */
  .top-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 8px 0 12px;
    margin-top: 0; /* ✅ prej 72px, zdaj container rešuje odmik */
  }

  /* ✅ vrstni red: search + gumbi najprej, datum zadnji */
  .controls-right { order: 1; }
  #day-header {
    order: 2;
    min-height: auto;
    pointer-events: none;
    align-self: flex-start;
    margin-top: 10px;   /* ✅ malo več lufta pod gumbi */
  }

  .controls-right {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .search-wrapper {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid rgba(255,255,255,0.25);
    border-radius: 10px;
    background: rgba(0,0,0,0.25);
    overflow: hidden;
  }

  .startlist-search {
    width: 100% !important;
    max-width: none !important;
    border: 0;
    background: transparent;
    outline: none;
    padding: 10px 44px 10px 12px;
    font-size: 16px;
    -webkit-appearance: none;
    appearance: none;
  }

  .clear-search {
    right: 14px;
    font-size: 18px;
    line-height: 1;
  }

  .top-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    width: 100%;
  }

  .top-btn {
    width: 100%;
    text-align: center;
  }

  /* entries */
  .startlist-entry {
    padding: 0.75rem 0.8rem;
    font-size: 1.05rem;
    border-radius: 12px;
  }

  .startlist-entry .inline {
    display: grid !important;
    grid-template-columns: 58px 32px 26px 1fr !important;
    grid-auto-rows: auto;
    column-gap: 10px;
    row-gap: 2px;
    align-items: center;
  }

  .inline span, .inline img {
    width: auto;
    margin: 0 !important;
  }

  .startlist-entry .inline > #countdown-timer,
  .startlist-entry .inline > :first-child {
    grid-column: 1 !important;
    grid-row: 1 / span 2 !important;
    align-self: center;
    text-align: right !important;
    min-width: 4.2ch;
  }

  .startlist-entry .inline > span:nth-child(2),
  .startlist-entry .start-number {
    display: block !important;
    grid-column: 2 !important;
    grid-row: 1 / span 2 !important;
    align-self: center;
    justify-self: end;
    min-width: 2.4rem;
    text-align: right !important;
    white-space: nowrap;
    opacity: 0.95;
  }

  .startlist-entry img.flag {
    grid-column: 3 !important;
    grid-row: 1 / span 2 !important;
    width: 24px;
    height: 16px;
    align-self: center;
    justify-self: start;
  }

  .startlist-entry .inline > span:nth-child(4) {
    grid-column: 4 !important;
    grid-row: 1 !important;
    font-weight: 600;
    font-size: 0.90rem;
    line-height: 1.2;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .startlist-entry .inline > .clubname {
    grid-column: 4 !important;
    grid-row: 2 !important;
    font-size: 0.70rem;
    color: #bfc3d9;
    opacity: 0.9;
    line-height: 1.15;
  }
}

/* =====================================================
   Print
===================================================== */
@media print {

  @page {
    size: A4;
    margin: 12mm;
    @bottom-right {
      content: counter(page) " / " counter(pages);
      font-size: 7.5pt;
      color: #1a1d38;
    }
  }

  html {
    font-size: 11px !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  body {
    background: #ffffff !important;
    color: #000000 !important;
    font-size: 10pt !important;
    margin: 0 !important;
  }

  * {
    animation: none !important;
    transition: none !important;
    box-shadow: none !important;
    text-shadow: none !important;
  }

  /* =====================================================
     Layout reset (no fixed / no scroll containers)
  ===================================================== */
  html, body { height: auto !important; overflow: visible !important; }

  .container,
  .content,
  .startlist,
  #startlist,
  #container {
    height: auto !important;
    overflow: visible !important;
  }

  /* Header (v printu NE fixed) */
  .main-header {
    position: static !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    box-shadow: none !important;
    break-inside: avoid !important;
    page-break-inside: avoid !important;
  }

  /* Container A4 width */
  .container {
    max-width: 190mm !important;
    margin: 0 auto !important;
    padding: 0 !important; /* nič dodatnega “lufta” */
  }

  /* =====================================================
     Top row: pokaži samo datum, skrij desni del
     (top-controls ostane, ker vsebuje #day-header)
  ===================================================== */
  .top-controls {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    gap: 12px !important;

    /* ✅ MIN razmak: glava -> datum */
    padding: 0 !important;
    margin: 4mm 0 2mm 0 !important;

    pointer-events: auto !important;
  }

  /* desni del (search + gumbi) skrij */
  .controls-right,
  .search-wrapper,
  .top-buttons,
  #startlist-search,
  #clear-search,
  #toggle-past,
  #print-pdf {
    display: none !important;
  }

  /* day header viden */
  #day-header {
    display: flex !important;
    pointer-events: auto !important;
    min-height: auto !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  #day-header .day-divider {
    display: flex !important;
    align-items: center !important;
    margin: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
  }

  /* datum: ohrani izgled (kot želiš) + črna za print */
  #day-header .day-divider-date {
    font-size: 1.4rem !important;   /* ⬅️ ostane kot na ekranu */
    font-weight: 800 !important;
    opacity: 0.95 !important;
    transform: translateY(1px) !important;
    color: #000000 !important;
    white-space: nowrap !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  /* ✅ zmanjša razmik med datumom in prvo kategorijo */
  .category-label {
    margin-top: 2mm !important;     /* prej 2rem -> preveč */
    margin-bottom: 1.5mm !important;
  }

  /* če se pojavljajo day-dividerji tudi v listi (med dnevi) */
  .day-divider {
    margin: 4mm 0 2mm 0 !important;
    padding: 0 !important;
    background: transparent !important;
    border: 0 !important;
  }

  /* =====================================================
     Print typography + layout for entries
     (povozi mobile grid)
  ===================================================== */
  .startlist-entry,
  .startlist-entry * {
    color: #000000 !important;
  }

  .startlist-entry br { display: inline !important; }

  .startlist-entry {
    background: #f2f4f8 !important;
    border: 1px solid #d6dbe6 !important;
    margin: 0.8mm 0 !important;
    padding: 1px 0 !important;
    border-radius: 8px !important;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  /* prisili desktop row layout */
  .startlist-entry .inline {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: baseline !important;

    font-size: 10pt !important;
    line-height: 1.15 !important;

    margin: 0 !important;
    padding: 1px 6px !important; /* malo notranjega roba */
    gap: 0.35rem !important;
  }

  /* time / countdown */
  .startlist-entry .inline > span:first-child,
  .startlist-entry .inline > #countdown-timer {
    width: 40px !important;
    text-align: right !important;
    min-width: 4.2ch !important;
    font-weight: 700 !important;
  }

  /* start number */
  .startlist-entry .inline > span:nth-child(2) {
    width: 24px !important;
    margin-left: 0 !important;
    text-align: center !important;
    font-weight: 700 !important;
  }

  /* flag slightly smaller */
  .startlist-entry img.flag {
    width: 16px !important;
    height: 12px !important;
    margin: 0 4px 0 2px !important;
  }

  /* title/team */
  .startlist-entry strong {
    font-size: 11.5pt !important;
    font-weight: 600 !important;
    line-height: 1.2 !important;
  }

  .startlist-entry .team,
  .startlist-entry .inline > span:nth-child(4) {
    font-size: 9pt !important;
    font-weight: 500 !important;
    line-height: 1.2 !important;
  }

  /* club */
  .startlist-entry em {
    font-size: 9pt !important;
    font-style: italic !important;
    font-weight: 400 !important;
    line-height: 1.15 !important;
    opacity: 1 !important;
  }

  .startlist-entry .clubname,
  .startlist-entry .inline > .clubname {
    display: inline !important;
    color: #000000 !important;
    opacity: 1 !important;
    white-space: nowrap !important;

    font-size: 7.5pt !important;
    font-style: italic !important;
    font-weight: 400 !important;
    line-height: 1.15 !important;

    margin: 0 !important;
    flex: 0 0 auto !important;
  }

  /* RESULTS marker */
  .startlist-entry.results-marker,
  .results-marker.startlist-entry,
  .results-marker {
    background-color: #5c2d91 !important;
    color: #ffffff !important;
    border: 0 !important;
  }

  .startlist-entry.results-marker *,
  .results-marker.startlist-entry * {
    color: #ffffff !important;
  }

  /* labels (Current / Next / Past) skrij */
  .section-label {
    display: none !important;
  }
}

.container .day-divider {
  margin-top: 46px;
}

#day-header .day-divider {
  margin-top: 0;
}

/* =====================================================
   Preliminary banner (visible only when start list is NOT official)
===================================================== */
.preliminary-banner{
  position: sticky;
  top: 64px;               /* tik pod fixed headerjem */
  z-index: 998;
  margin: 0;
  padding: 10px 14px;
  text-align: center;

  background: rgba(197, 138, 27, 0.95); /* amber */
  color: #000;
  font-weight: 900;
  letter-spacing: .6px;
  text-transform: uppercase;

  border-bottom: 2px solid rgba(255,255,255,0.35);
  box-shadow: 0 4px 8px rgba(0,0,0,0.35);
}

/* =====================================================
   STALE DATA WARNING BANNER
   (enaka logika kot .preliminary-banner)
===================================================== */

.stale-data-banner{
  position: sticky;
  top: 64px;               /* tik pod fixed headerjem */
  z-index: 998;
  margin: 0;
  padding: 10px 14px;
  text-align: center;

  background: rgba(180, 40, 40, 0.95); /* rdeče opozorilo */
  color: #fff;
  font-weight: 900;
  letter-spacing: .6px;
  text-transform: uppercase;

  border-bottom: 2px solid rgba(255,255,255,0.35);
  box-shadow: 0 4px 8px rgba(0,0,0,0.35);
}

/* Mobile: banner malo nižje, da se ne skrije */
@media (max-width: 768px){
  .preliminary-banner{
    top: 78px; /* ✅ prej 64px */
    font-size: 0.95rem;
    padding: 9px 12px;
  }
}

/* Print: pokaži tudi v printu (če je preliminary) */
@media print{
  .preliminary-banner{
    position: static !important;
    top: auto !important;
    margin: 2mm 0 2mm 0 !important;
    padding: 2mm 0 !important;
    background: #f0c04a !important;
    color: #000 !important;
    box-shadow: none !important;
    border: 1px solid #caa23f !important;
  }
}
