/* Mobile-first tweaks voor Egon's tennisplanner */

:root {
  --tap: 44px; /* minimum touch target height */
}

/* === BASE STYLING === */
html { 
  font-size: 16px; /* voorkomt iOS auto-zoom */
}

body { 
  -webkit-text-size-adjust: 100%;
  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);
}

/* === TOUCH TARGETS === */
button, .btn, input, select { 
  min-height: var(--tap);
  line-height: 1.2;
  padding: 0.6rem 1rem;
  border-radius: 0.75rem;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

a, textarea {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* === LAYOUT === */
.cards { gap: 14px; }
.card { 
  padding: 14px;
  border-radius: 14px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.06);
}
.row { gap: 10px; }
.badge { 
  padding: 6px 12px;
  border-radius: 999px;
  font-weight: 600;
}

/* === HEADER === */
.header, .topbar, header[role="banner"] {
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: saturate(1.1) blur(6px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.header .brand {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 0 1 auto;
}

.brand-logo {
  width: clamp(56px, 7vw, 88px);
  height: auto;
  aspect-ratio: 1/1;
  display: block;
}

.brand-text .brand-title {
  margin: 0;
  line-height: 1;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.brand-text .brand-title .thin {
  font-weight: 600;
  opacity: 0.9;
}

.week-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 700;
  background: #e8f6ee;
  color: #1e7f4d;
  border: 1px solid #bfe7cf;
  transform: translateY(2px);
}

.nav {
  display: flex;
  gap: 8px;
  flex: 1 1 260px;
  justify-content: flex-end;
}

/* === ICON BUTTONS === */
.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

.icon-btn {
  width: 44px;
  height: 44px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
}

.icon-btn svg, .nav button svg, .btn.icon-btn svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
}

/* === SCROLL BEHAVIOR === */
.scroller, .cards, .table-wrap {
  overscroll-behavior: contain;
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* === TABLES === */
table {
  table-layout: auto;
}

table th, table td {
  padding: 8px 6px;
}

.table.compact th, .table.compact td {
  padding: 6px 8px;
}

/* === DIALOGS === */
dialog {
  border: none;
  border-radius: 16px;
  padding: 20px;
  max-height: 90vh;
  overflow: hidden;
  box-sizing: border-box;
}

dialog::backdrop {
  background: rgba(0,0,0,0.3);
}

dialog .dialog-body {
  padding: 0;
  max-height: calc(90vh - 56px);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

dialog h1, dialog h2, dialog h3 {
  margin: 0 0 8px;
}

dialog p {
  margin: 8px 0;
}

dialog input, dialog select, dialog textarea {
  width: 100%;
  box-sizing: border-box;
  font: inherit;
  padding: 0.55rem 0.7rem;
  border-radius: 0.6rem;
  margin-top: 8px;
}

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

:root:has(dialog[open]) body {
  overflow: hidden;
}

/* === BESCHIKBAARHEID WEEK-GRID === */
.weeks-wrap {
  display: grid;
  gap: 12px;
}

.week-card .week-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.week-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}

.day-tile {
  border: 1px solid #e4e8ee;
  border-radius: 12px;
  background: #fff;
  padding: 10px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  min-height: 72px;
  transition: box-shadow 0.15s ease, transform 0.05s ease;
}

.day-tile .day-label {
  font-weight: 700;
  color: #334;
}

.day-tile.available {
  border-left: 4px solid #2ecc71;
}

.day-tile.unavailable {
  border-left: 4px solid #ff6b6b;
  background: #fff8f8;
}

.day-tile:active {
  transform: translateY(1px);
}

.pill {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.85rem;
}

/* === STATISTIEKEN TIJDBALK === */
.legend {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.legend .leg {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid rgba(0,0,0,0.15);
  vertical-align: middle;
}

.legend .leg-play {
  background: #2ecc71;
  border-color: #2ecc71;
}

.legend .leg-no {
  background: #ff6b6b;
  border-color: #ff6b6b;
}

.timeline-wrap {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 12px;
  border: 1px solid rgba(0,0,0,0.08);
}

.timeline-header, .timeline-row {
  display: grid;
  grid-template-columns: 160px 1fr;
  align-items: center;
}

.timeline-header {
  position: sticky;
  left: 0;
  background: rgba(255,255,255,0.9);
  backdrop-filter: saturate(1.1) blur(4px);
  z-index: 1;
}

.tl-label {
  padding: 10px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-right: 1px solid rgba(0,0,0,0.06);
}

.tl-cells {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 22px;
  gap: 4px;
  padding: 8px;
}

.tl-cell {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  border: 1px solid rgba(0,0,0,0.1);
}

.tl-date {
  background: #f2f2f2;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
}

.tl-play {
  background: #2ecc71;
  border-color: #27ae60;
}

.tl-no {
  background: #ff6b6b;
  border-color: #e74c3c;
}

/* === RESPONSIVE: SMALL SCREENS === */
@media (max-width: 520px) {
  .toolbar {
    gap: 8px;
    flex-wrap: wrap;
  }
  
  .toolbar .btn {
    padding: 0.55rem 0.75rem;
  }
  
  .grid2, .grid3 {
    display: grid;
    grid-template-columns: 1fr !important;
    gap: 12px;
  }
  
  dialog {
    width: 94vw;
    max-width: 420px;
  }
  
  .brand-text .brand-title {
    font-size: 1.05rem;
  }
  
  .week-chip {
    padding: 4px 10px;
    font-size: 0.8rem;
  }
}

@media (max-width: 560px) {
  .week-chip {
    font-size: 0.8rem;
    padding: 4px 10px;
  }
}

@media (max-width: 600px) {
  .header .brand .brand-logo {
    width: 96px !important;
  }
}

/* === DARK MODE === */
@media (prefers-color-scheme: dark) {
  body {
    background: #0f1115;
    color: #e7e8ea;
  }
  
  .card {
    background: #151923;
    box-shadow: none;
  }
  
  table {
    color: inherit;
  }
  
  .timeline-wrap {
    border-color: rgba(255,255,255,0.08);
  }
  
  .timeline-header {
    background: rgba(20,20,24,0.85);
  }
  
  .tl-date {
    background: #1e2330;
    color: #cfd3dc;
    border-color: rgba(255,255,255,0.08);
  }
  
  .tl-label {
    border-color: rgba(255,255,255,0.08);
  }
  
  .tl-cell {
    border-color: rgba(255,255,255,0.08);
  }
}