/*
  Egon's Tennisplanner – Mobile CSS v2 (modern redesign)
  Doel: strakker dashboard, vaste badges (COMPETITIE/VRIJ SPELEN) zonder verspringen,
  betere hiërarchie, behoud van bestaande functionaliteit/HTML.
*/

:root{
  --tap: 44px;

  --bg: #f6f7fb;
  --panel: #ffffff;
  --panel-2: #fbfcff;
  --text: #0f172a;
  --muted: rgba(15,23,42,.68);
  --line: rgba(15,23,42,.10);
  --line-2: rgba(15,23,42,.08);

  --shadow: 0 10px 30px rgba(2, 6, 23, .08);
  --shadow-sm: 0 6px 18px rgba(2, 6, 23, .08);

  --r-lg: 18px;
  --r-md: 14px;
  --r-sm: 12px;

  --accent: #2563eb;
  --good: #16a34a;
  --warn: #f59e0b;
  --bad:  #ef4444;

  --chip-blue-bg: rgba(37, 99, 235, .10);
  --chip-blue-bd: rgba(37, 99, 235, .22);
  --chip-blue-tx: #1d4ed8;

  --chip-gold-bg: rgba(245, 158, 11, .16);
  --chip-gold-bd: rgba(245, 158, 11, .28);
  --chip-gold-tx: #92400e;

  --chip-green-bg: rgba(22, 163, 74, .12);
  --chip-green-bd: rgba(22, 163, 74, .22);
  --chip-green-tx: #166534;

  --chip-gray-bg: rgba(15, 23, 42, .05);
  --chip-gray-bd: rgba(15, 23, 42, .10);
  --chip-gray-tx: rgba(15, 23, 42, .78);
}

html{ font-size:16px; }
body{
  -webkit-text-size-adjust: 100%;
  background: var(--bg);
  color: var(--text);
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

/* --- Links & focus --- */
a{ color: var(--accent); }
:focus-visible{ outline: 3px solid rgba(37,99,235,.28); outline-offset: 2px; border-radius: 10px; }

/* --- Buttons / inputs --- */
button,.btn,input,select,textarea{
  min-height: var(--tap);
  border-radius: 12px;
  font: inherit;
  line-height: 1.2;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

input,select,textarea{
  background: #fff;
  border: 1px solid var(--line);
  padding: .6rem .75rem;
}

.btn,button{
  border: 1px solid var(--line);
  background: #fff;
  padding: .65rem .95rem;
  box-shadow: 0 1px 0 rgba(2,6,23,.04);
}
.btn:hover,button:hover{ box-shadow: var(--shadow-sm); }
.btn:active,button:active{ transform: translateY(1px); }

.btn.primary, button.primary{
  background: var(--accent);
  border-color: rgba(37,99,235,.35);
  color: #fff;
  box-shadow: 0 10px 18px rgba(37,99,235,.18);
}

.btn.ghost,button.ghost{
  background: transparent;
}

.btn.danger,button.danger{
  background: rgba(239,68,68,.08);
  border-color: rgba(239,68,68,.20);
  color: #b91c1c;
}

/* --- Header / topbar --- */
.header, .topbar, header[role="banner"]{
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(10px) saturate(1.2);
  background: color-mix(in srgb, var(--bg) 70%, white 30%);
  border-bottom: 1px solid var(--line-2);
}

.header > *, .topbar > *{ padding: 10px 14px; }

.header .brand, .topbar .brand{
  display:flex;
  align-items:center;
  gap: 12px;
}

.brand-logo{ width: 48px; height:auto; border-radius: 12px; }

.week-chip{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-width: 86px;
  height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  font-weight: 800;
  background: var(--chip-green-bg);
  border: 1px solid var(--chip-green-bd);
  color: var(--chip-green-tx);
}

.user-chip{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  font-weight: 800;
  background: color-mix(in srgb, var(--panel) 70%, white 30%);
  border: 1px solid var(--line-2);
  color: var(--text);
  white-space: nowrap;
}

.nav{
  display:flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.icon-btn{
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 14px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  background: #fff;
}
.icon-btn svg{ width: 22px; height: 22px; }

/* --- Cards layout --- */
.cards{ display:flex; flex-direction:column; gap: 14px; }
.card{
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 16px;
  box-shadow: var(--shadow);
}

h1,h2,h3{ letter-spacing: -0.01em; }

/* --- Dashboard title row ("Mijn wedstrijden" etc.) --- */
.section-title,
.card > h2,
.card > h3{
  display:flex;
  align-items:center;
  gap: 10px;
}

/* --- Pills / badges (algemeen) --- */
.badge, .pill, .chip{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--chip-gray-bd);
  background: var(--chip-gray-bg);
  color: var(--chip-gray-tx);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .02em;
  text-transform: none;
  white-space: nowrap;
}

/* Week badge (fix: vaste breedte zodat niets verspringt) */
.badge.week, .week-badge, .match-week, .week-pill{
  min-width: 74px;
  background: var(--chip-green-bg);
  border-color: var(--chip-green-bd);
  color: var(--chip-green-tx);
}

/* Match type badge (fix: vaste breedte) */
.match-kind, .match-type, .badge.kind{
  min-width: 112px; /* COMPETITIE vs VRIJ SPELEN blijft strak */
  justify-content: center;
}

.kind-competition, .badge.kind-competition{
  background: var(--chip-gold-bg);
  border-color: var(--chip-gold-bd);
  color: var(--chip-gold-tx);
}

.kind-regular, .badge.kind-regular{
  background: var(--chip-blue-bg);
  border-color: var(--chip-blue-bd);
  color: var(--chip-blue-tx);
}

/* --- Match cards --- */
.match-card{
  background: linear-gradient(180deg, var(--panel) 0%, var(--panel-2) 100%);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 14px;
  box-shadow: 0 1px 0 rgba(2,6,23,.04);
}

.match-head{
  display:grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: start;
}

/* Titelregel: datum + tijd + type badge netjes */
.match-title{
  font-weight: 900;
  font-size: 1.06rem;
  line-height: 1.15;
  margin: 0;
}

/* Als de type badge in dezelfde regel staat als de titel */
.match-title .match-kind,
.match-title .match-type,
.match-title .badge.kind{
  margin-left: 10px;
  vertical-align: middle;
}

/* Alternatieve layout als de badge los staat */
.match-kind{ margin-top: 2px; }

.match-meta,.match-players,.match-note{
  margin-top: 8px;
  color: var(--muted);
}

.match-players b,.match-meta b{ color: rgba(15,23,42,.88); }

/* Actieknoppen rij binnen match */
.match-actions, .actions-row{
  display:flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
  margin-top: 12px;
}

/* Nette rij met week-badge rechts */
.match-right{
  display:flex;
  align-items:flex-start;
  justify-content:flex-end;
  gap: 10px;
}

/* Als week-badge in de match-head zit */
.match-head .badge.week,
.match-head .match-week,
.match-head .week-badge,
.match-head .week-pill{
  margin-top: 2px;
}

/* --- Tables / scrollers --- */
.table-wrap{ overflow-x:auto; -webkit-overflow-scrolling: touch; }

/* --- Dialogs --- */
dialog{
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  max-height: 90vh;
  box-shadow: var(--shadow);
}

dialog::backdrop{ background: rgba(2,6,23,.35); }

dialog .actions, dialog .buttons, dialog footer{
  display:flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 14px;
}

/* --- Availability/timeline helpers (blijf compatibel) --- */
.table-wrap, .scroller, .cards{ overscroll-behavior: contain; }

/* --- Small screens --- */
@media (max-width: 520px){
  .header > *, .topbar > *{ padding: 10px 12px; }
  .card{ padding: 14px; }
  .match-card{ padding: 12px; }
  .match-actions .btn, .actions-row .btn{ flex: 1 1 auto; }
}

/* --- Reduced motion --- */
@media (prefers-reduced-motion: reduce){
  *{ scroll-behavior: auto !important; transition: none !important; }
}

/* =============================
   HOTFIX v2 (nav + week alignment)
   ============================= */

/* Top-right nav/action buttons: keep them as tidy squares.
   Many builds render button text next to/over icons; we hide that text
   so the header stays clean and doesn't overlap.
*/
.topbar nav,
.topbar .nav,
.topbar .nav-actions,
.topbar .actions,
.header nav,
.header .nav,
.header .nav-actions,
.header .actions{
  display:flex;
  align-items:center;
  gap: 10px;
  flex-wrap: nowrap;
}

/* Generic nav buttons/links (ids like nav-dashboard/nav-availability/etc.) */
button[id^="nav-"],
a[id^="nav-"]{
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  font-size: 0; /* hide any stray label text */
}

button[id^="nav-"] svg,
a[id^="nav-"] svg,
button[id^="nav-"] img,
a[id^="nav-"] img{
  width: 22px;
  height: 22px;
}

/* If there *is* an explicit label element, keep it hidden in the header */
button[id^="nav-"] .label,
a[id^="nav-"] .label,
button[id^="nav-"] .text,
a[id^="nav-"] .text{
  display: none !important;
}

/* ====== Match cards: align week badge in a fixed right column ====== */

/* Dashboard: tabs (Mijn wedstrijden / Volledig schema) */
.tabs{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
}
.tab-btn{
  border:1px solid #e1e5e9;
  background:#fff;
  border-radius:999px;
  padding:8px 12px;
  font-weight:800;
  cursor:pointer;
}
.tab-btn.is-active{
  background:#667eea1a;
  border-color:#667eea55;
}

/* Dashboard match rows (consistent alignment between vrij spelen & competitie) */
.match-row{
  border:1px solid #e1e5e9;
  border-radius:12px;
  padding:12px;
  background:linear-gradient(180deg,#ffffff,#f7f9ff);
  display:grid;
  grid-template-columns: 1fr minmax(240px, 460px);
  gap:14px;
  align-items:start;
}
.match-left .match-top{
  display:flex;
  gap:8px;
  align-items:center;
  flex-wrap:wrap;
}
.match-title{ font-weight:800; color:#28a745; }
.match-players{ font-size:14px; color:#333; margin-top:4px; }
.match-right{ display:flex; flex-direction:column; align-items:flex-end; gap:10px; }
.match-actions{ display:flex; gap:8px; flex-wrap:wrap; justify-content:flex-end; }
.match-week{ min-width:76px; text-align:center; }

@media (max-width: 900px){
  .match-row{
    grid-template-columns: 1fr;
  }
  .match-right{ align-items:flex-start; }
  .match-actions{ justify-content:flex-start; }
}

/* Ensure the header area of a match uses a stable two-column grid */
.match-head,
.match-row,
.match{
  /* if these are not grids in some builds, this won't break anything */
}

/* Common pattern in this app: a left block and a right "chips + buttons" block.
   We enforce a two-column layout where possible.
*/
.match-head{
  display: grid;
  grid-template-columns: 1fr minmax(240px, 460px);
  gap: 14px;
  align-items: start;
}

.match-right,
.match-meta-right,
.match-actions-right{
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  min-width: 240px;
}

/* Week pill should have a consistent width so all rows line up */
.badge.week,
.pill.week,
.week-pill,
span.week,
.week{
  min-width: 76px;
  text-align: center;
}

/* Action buttons row: keep aligned right, wrap nicely */
.match-actions,
.actions,
.btn-row{
  justify-content: flex-end;
  flex-wrap: wrap;
}

/* Responsive: on smaller widths, stack the right column under the left */
@media (max-width: 900px){
  .match-head{
    grid-template-columns: 1fr;
  }
  .match-right,
  .match-meta-right,
  .match-actions-right{
    min-width: 0;
    width: 100%;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}



/* ====== Header/nav layout safeguards ====== */
.top-actions,
.topbar-actions,
.header-actions,
.nav-actions,
.actions-row,
.topbar .actions,
.header .actions{
  display:flex;
  align-items:center;
  gap:10px;
  flex-wrap:nowrap;
  white-space:nowrap;
  overflow-x:auto;
}
