*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --tppwb: #27ae60;
  --afpadel: #2980b9;
  --tpv: #e67e22;
  --multi: #8e44ad;
  --header-bg: #1a2f4e;
  --text-primary: #2c3e50;
  --text-muted: #7f8c8d;
  --border: #e2e8f0;
  --bg-sidebar: #f8fafc;
  --shadow-sm: 0 1px 4px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.12);
  --radius: 10px;
  --sidebar-w: 380px;
}

html, body {
  height: 100%;
  font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--text-primary);
  background: #eef2f7;
  overflow: hidden;
}

body {
  display: flex;
  flex-direction: column;
}

/* ─── HEADER ─────────────────────────────────────────── */
.header {
  background: var(--header-bg);
  color: #fff;
  height: 56px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  z-index: 1000;
  box-shadow: 0 2px 10px rgba(0,0,0,0.25);
  flex-shrink: 0;
}

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

.header-logo {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.header-sep {
  width: 1px;
  height: 20px;
  background: rgba(255,255,255,0.25);
}

.header-sub {
  font-size: 13px;
  color: rgba(255,255,255,0.6);
}

.header-legend {
  display: flex;
  align-items: center;
  gap: 16px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: rgba(255,255,255,0.8);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ─── MOBILE TABS ─────────────────────────────────────── */
.mobile-tabs {
  display: none;
  background: #142540;
  flex-shrink: 0;
}

.mobile-tab {
  flex: 1;
  padding: 9px 0;
  text-align: center;
  font-size: 13px;
  font-weight: 500;
  color: rgba(255,255,255,0.55);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: all 0.2s;
  user-select: none;
}

.mobile-tab.active {
  color: #fff;
  border-bottom-color: var(--afpadel);
}

/* ─── LAYOUT ──────────────────────────────────────────── */
.app-container {
  display: flex;
  flex: 1;
  min-height: 0;
}

/* ─── SIDEBAR ─────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: #fff;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  overflow: hidden;
}

.sidebar-controls {
  padding: 14px 14px 10px;
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border);
}

/* Search */
.search-box {
  position: relative;
  margin-bottom: 13px;
}

.search-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 15px;
  pointer-events: none;
}

.search-box input {
  width: 100%;
  padding: 9px 14px 9px 36px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 13.5px;
  color: var(--text-primary);
  background: #fff;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-box input:focus {
  border-color: var(--afpadel);
  box-shadow: 0 0 0 3px rgba(41,128,185,0.1);
}

.search-box input::placeholder {
  color: #b0bec5;
}

/* Filter groups */
.filter-group {
  margin-bottom: 11px;
}

.filter-label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin-bottom: 7px;
}

/* Federation pills */
.fed-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.fed-pill {
  padding: 5px 11px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border: 1.5px solid var(--border);
  background: #fff;
  color: var(--text-primary);
  transition: all 0.15s;
  white-space: nowrap;
}

.fed-pill:hover {
  border-color: #aac;
  background: #f0f4f8;
}

.fed-pill.active {
  color: #fff;
  border-color: transparent;
}

.fed-pill[data-fed="all"].active       { background: var(--header-bg); }
.fed-pill[data-fed="TPPWB"].active     { background: var(--tppwb); }
.fed-pill[data-fed="AFPadel"].active   { background: var(--afpadel); }
.fed-pill[data-fed="Tennis Padel Vlaanderen"].active { background: var(--tpv); }

/* Province select */
.filter-select {
  width: 100%;
  padding: 8px 11px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-primary);
  background: #fff;
  outline: none;
  cursor: pointer;
  appearance: auto;
}

.filter-select:focus {
  border-color: var(--afpadel);
}

/* Tournament grid */
.tournament-grid {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.t-row {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.t-cat-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  width: 22px;
  flex-shrink: 0;
}

.tournament-pill {
  padding: 4px 11px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid var(--border);
  background: #fff;
  color: var(--text-muted);
  transition: all 0.15s;
}

.tournament-pill:hover {
  border-color: var(--text-primary);
  color: var(--text-primary);
}

.tournament-pill.active {
  background: var(--text-primary);
  border-color: var(--text-primary);
  color: #fff;
}

/* ─── LIST HEADER ─────────────────────────────────────── */
.list-header {
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: #fff;
  flex-shrink: 0;
}

.clubs-count {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}

.reset-btn {
  font-size: 12px;
  color: var(--afpadel);
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 0;
  font-weight: 500;
  text-decoration: none;
  transition: opacity 0.15s;
}

.reset-btn:hover {
  opacity: 0.75;
  text-decoration: underline;
}

/* ─── CLUBS LIST ──────────────────────────────────────── */
.clubs-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e0 transparent;
}

.clubs-list::-webkit-scrollbar { width: 5px; }
.clubs-list::-webkit-scrollbar-thumb { background: #cbd5e0; border-radius: 4px; }

.empty-state {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
}

.empty-state p:first-child {
  font-size: 15px;
  font-weight: 500;
  margin-bottom: 6px;
  color: #4a5568;
}

.empty-state p:last-child {
  font-size: 13px;
}

/* Club card */
.club-card {
  padding: 12px 14px;
  border-radius: var(--radius);
  margin-bottom: 6px;
  cursor: pointer;
  border: 1.5px solid var(--border);
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
}

.club-card:hover {
  border-color: #90cdf4;
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.club-card.active {
  border-color: var(--afpadel);
  background: #f0f7ff;
  box-shadow: 0 0 0 3px rgba(41,128,185,0.12);
}

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 8px;
}

.club-name {
  font-weight: 600;
  font-size: 13.5px;
  color: var(--text-primary);
  line-height: 1.3;
}

.club-location {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 3px;
}

.card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 7px;
}

.fed-badge {
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 10.5px;
  font-weight: 600;
  color: #fff;
  line-height: 1.4;
}

.fed-badge.tppwb   { background: var(--tppwb); }
.fed-badge.afpadel { background: var(--afpadel); }
.fed-badge.tpv     { background: var(--tpv); }
.fed-badge.multi   { background: var(--multi); }

.card-tournaments {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.t-tag {
  padding: 2px 7px;
  background: #eef2f7;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  color: #4a5568;
}

/* ─── MAP ─────────────────────────────────────────────── */
.map-container {
  flex: 1;
  position: relative;
  min-width: 0;
}

#map {
  width: 100%;
  height: 100%;
}

/* Map reset view button */
.map-btn {
  position: absolute;
  bottom: 30px;
  right: 10px;
  z-index: 999;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background 0.15s;
}

.map-btn:hover {
  background: #f0f4f8;
}

/* ─── LEAFLET OVERRIDES ───────────────────────────────── */
.leaflet-popup-content-wrapper {
  border-radius: 12px !important;
  box-shadow: var(--shadow-md) !important;
  padding: 0 !important;
}

.leaflet-popup-content {
  margin: 14px 16px !important;
}

.leaflet-popup-tip-container {
  margin-top: -1px;
}

/* Popup content */
.popup-name {
  font-weight: 700;
  font-size: 14.5px;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.popup-location {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 9px;
}

.popup-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 9px;
}

.popup-row {
  font-size: 12px;
  color: #4a5568;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.popup-icon {
  width: 14px;
  text-align: center;
  color: var(--text-muted);
  flex-shrink: 0;
}

.popup-tournaments {
  margin-top: 9px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.t-section {
  margin-bottom: 8px;
}

.t-section:last-child {
  margin-bottom: 0;
}

.t-section-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 5px;
}

.t-entry {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin-bottom: 4px;
}

.t-entry:last-child {
  margin-bottom: 0;
}

.t-date {
  font-size: 11px;
  color: #4a5568;
  font-weight: 500;
}

.t-name {
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
}

.t-fed-badge {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.3px;
  padding: 1px 5px;
  border-radius: 4px;
  color: #fff;
  white-space: nowrap;
  opacity: 0.9;
}
.t-fed-badge.tppwb  { background: #27ae60; }
.t-fed-badge.afpadel { background: #2980b9; }
.t-fed-badge.tpv    { background: #e67e22; }
.t-fed-badge.multi  { background: #8e44ad; }

/* Custom map markers */
.map-marker {
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.35);
  transition: transform 0.1s;
}

.map-marker:hover {
  transform: scale(1.2);
}

/* ─── SITE FOOTER ────────────────────────────────────── */
.site-footer {
  flex-shrink: 0;
  background: #fff;
  border-top: 1px solid var(--border);
  padding: 8px 20px;
  z-index: 999;
}

.site-footer-inner {
  max-width: 1100px;
  margin: 0 auto;
  font-size: 10.5px;
  color: var(--text-muted);
  line-height: 1.6;
  text-align: center;
}

.site-footer-inner p { margin: 0; }

.site-footer-inner strong {
  color: var(--text-primary);
  font-weight: 600;
}

.site-footer-disclaimer {
  color: #a0aab4;
  font-size: 10px;
}

.site-footer-inner a {
  color: var(--afpadel);
  text-decoration: none;
}

.site-footer-inner a:hover { text-decoration: underline; }

/* ─── HEADER RIGHT ────────────────────────────────────── */
.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* ─── MES TOURNOIS BUTTON ─────────────────────────────── */
.mes-tournois-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: rgba(255,255,255,0.1);
  border: 1.5px solid rgba(255,255,255,0.25);
  border-radius: 8px;
  color: rgba(255,255,255,0.85);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.mes-tournois-btn:hover {
  background: rgba(255,255,255,0.18);
  border-color: rgba(255,255,255,0.45);
  color: #fff;
}

.mes-tournois-btn.active {
  background: var(--afpadel);
  border-color: var(--afpadel);
  color: #fff;
}

/* ─── FAV COUNTER BADGE ───────────────────────────────── */
.fav-counter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: #e67e22;
  color: #fff;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 700;
}

/* ─── STAR (FAV) BUTTON ───────────────────────────────── */
.card-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.fav-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 15px;
  color: #cbd5e0;
  padding: 2px 3px;
  line-height: 1;
  border-radius: 4px;
  transition: color 0.15s;
}

.fav-btn:hover { color: #f6ad55; }
.fav-btn.active { color: #f6a623; }

/* ─── POPUP HEADER ────────────────────────────────────── */
.popup-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 2px;
}

.popup-header .popup-name {
  flex: 1;
  margin-bottom: 0;
}

.fav-btn-popup {
  font-size: 18px;
  flex-shrink: 0;
  margin-top: -1px;
}

/* ─── MES TOURNOIS PANEL ──────────────────────────────── */
#mes-tournois-panel {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  background: var(--bg-sidebar);
  padding: 24px;
}

.mt-container {
  max-width: 800px;
  margin: 0 auto;
}

.mt-header {
  background: #fff;
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.mt-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}

.mt-meta {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

.mt-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.mt-club-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  background: var(--header-bg);
  color: rgba(255,255,255,0.9);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: opacity 0.15s;
}

.mt-club-chip:hover { opacity: 0.8; }

.mt-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 16px;
  padding: 8px 16px;
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.mt-back-btn:hover {
  border-color: var(--afpadel);
  color: var(--afpadel);
  box-shadow: var(--shadow-sm);
}

.mt-month-group { margin-bottom: 24px; }

.mt-month-header {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  padding-bottom: 8px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 10px;
}

.mt-entry {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.mt-entry:hover {
  border-color: var(--afpadel);
  box-shadow: var(--shadow-sm);
}

.mt-entry-date {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  min-width: 148px;
  flex-shrink: 0;
  padding-top: 2px;
  white-space: nowrap;
}

.mt-entry-body { flex: 1; min-width: 0; }

.mt-entry-name {
  font-weight: 600;
  font-size: 13.5px;
  color: var(--text-primary);
  margin-bottom: 3px;
}

.mt-entry-club {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.mt-entry-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.mt-empty {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-muted);
}

.mt-empty-icon { font-size: 40px; margin-bottom: 14px; }
.mt-empty-title { font-size: 16px; font-weight: 600; color: #4a5568; margin-bottom: 8px; }
.mt-empty-sub { font-size: 13px; line-height: 1.5; max-width: 320px; margin: 0 auto; }

/* ─── RESPONSIVE ──────────────────────────────────────── */
@media (max-width: 900px) {
  :root { --sidebar-w: 320px; }
  .header-legend { display: none; }
  .mes-tournois-btn { font-size: 12px; padding: 6px 10px; }
}

@media (max-width: 700px) {
  .app-container {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    min-width: unset;
  }

  .mobile-tabs {
    display: flex;
  }

  /* map-first / list-first toggle via body classes */
  body.show-map .sidebar       { display: none; }
  body.show-map .map-container { height: 100%; flex: 1; }
  body.show-list .map-container { display: none; }
  body.show-list .sidebar      { flex: 1; height: 100%; }

  /* default: split 50/50 */
  .map-container { height: 50%; }
  .sidebar       { height: 50%; }

  .header-sub, .header-sep { display: none; }
  .header-logo { font-size: 16px; }

  #mes-tournois-panel {
    padding: 12px;
  }

  .mt-entry {
    flex-direction: column;
    gap: 6px;
  }

  .mt-entry-date { min-width: unset; }
}
