/* --- CSS VARIABLES (Kleuren & Thema's) --- */
:root {
  /* Default: DARK MODE */
  --bg-body: #0f172a;
  --bg-sidebar: #1e293b;
  --bg-card: #1e293b;
  --bg-header: #1e293b;
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --border: #334155;
  --accent: #22c55e;       /* Groen */
  --accent-hover: #16a34a;
  --danger: #ef4444;       /* Rood */
  
  --font-family: 'Inter', system-ui, sans-serif, 'Noto Color Emoji';
}

/* LIGHT MODE OVERRIDES */
body.light-mode {
  --bg-body: #f3f4f6;
  --bg-sidebar: #ffffff;
  --bg-card: #ffffff;
  --bg-header: #ffffff;
  --text-main: #1f2937;
  --text-muted: #6b7280;
  --border: #e5e7eb;
}

/* --- BASIS STYLES --- */
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font-family);
  background: var(--bg-body);
  color: var(--text-main);
  height: 100vh;
  overflow: hidden; /* Scrollen gebeurt in de main area */
}

/* --- LAYOUT (Sidebar + Main) --- */
.app-layout {
  display: flex;
  height: 100vh;
}

/* SIDEBAR (Desktop) */
.sidebar {
  width: 240px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px;
  flex-shrink: 0;
  height: 100vh; 
  overflow: hidden;
}

.brand {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 800;
  color: var(--accent);
  margin-bottom: 20px;
}

.nav-links {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1; 
  overflow-y: auto; /* Scrollen als lijst te lang is */
  min-height: 0;
  margin-bottom: 20px;
  
  /* Mooiere scrollbar */
  scrollbar-width: thin; 
  scrollbar-color: var(--border) transparent;
}

.nav-item {
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  transition: 0.2s;
  display: flex;
  align-items: center;
}

.nav-item span {
  margin-right: 10px; /* Icoon naast tekst op desktop */
}

.nav-item:hover {
  background: rgba(128, 128, 128, 0.1);
  color: var(--text-main);
}

.nav-item.active {
  background: var(--accent);
  color: #06250f; 
  font-weight: 700;
}

.sidebar-footer {
  flex-shrink: 0; 
  border-top: 1px solid var(--border);
  padding-top: 20px;
}

.version-muted { font-size: 11px; color: var(--text-muted); margin-top: 10px; text-align: center; }

/* MAIN CONTENT */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.top-header {
  height: 70px;
  background: var(--bg-header);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 30px;
}

.stats-group {
  display: flex;
  gap: 25px;
}

.stat-item {
  display: flex;
  flex-direction: column;
}

.stat-item .label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.stat-item strong { font-size: 16px; }

.actions-group {
  display: flex;
  gap: 10px;
}

/* VIEW CONTAINER */
.view-container {
  flex: 1;
  overflow-y: auto;
  padding: 30px;
}

/* --- COMPONENTS --- */

/* RESPONSIVE GRID (Voor dashboard blokken) */
.responsive-grid {
  display: grid;
  gap: 15px;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  margin-bottom: 20px;
}

/* CARDS */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  overflow-x: auto; /* Zorgt dat tabellen scrollen op mobiel */
}

h1, h2, h3 { margin-top: 0; }
h2 { font-size: 20px; margin-bottom: 15px; }
.muted { color: var(--text-muted); }

/* BUTTONS */
button {
  padding: 8px 16px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-main);
  cursor: pointer;
  font-weight: 600;
  transition: 0.2s;
}
button:hover { filter: brightness(95%); }

button.primary { background: var(--accent); color: #06250f; border: none; }
button.primary:hover { filter: brightness(110%); }

button.danger { background: var(--danger); color: white; border: none; }

button.secondary { background: rgba(128,128,128,0.2); border: none; }

/* THEMA KNOP (HEADER) */
.btn-icon {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-main);
  font-size: 20px;
  padding: 5px 10px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
}
.btn-icon:hover { background: rgba(255, 255, 255, 0.1); transform: scale(1.1); }

/* KOFFIE KNOP (SIDEBAR) */
.btn-coffee {
  display: block;
  text-align: center;
  background: #FFDD00;
  color: #000;
  text-decoration: none;
  padding: 10px;
  border-radius: 8px;
  font-weight: bold;
  font-size: 13px;
  margin-bottom: 10px;
  transition: transform 0.2s;
}
.btn-coffee:hover { transform: scale(1.02); }

/* TABLE */
table { width: 100%; border-collapse: collapse; min-width: 500px; /* Zorgt voor scroll op mobiel */ }
th, td { text-align: left; padding: 12px; border-bottom: 1px solid var(--border); }
th { color: var(--text-muted); font-size: 12px; text-transform: uppercase; }
tbody tr { transition: background 0.15s; }
tbody tr:hover { background: rgba(128,128,128,0.07); }
.pill { background: rgba(128,128,128,0.15); padding: 4px 8px; border-radius: 99px; font-size: 12px; font-weight: bold; }
.pill-gk { background: rgba(234,179,8,0.2); color: #eab308; }

/* Vorm-indicator (laatste 5 duels) */
.form-chip {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%;
  font-size: 11px; font-weight: 800; color: #fff;
}
.form-w { background: #22c55e; }
.form-d { background: #94a3b8; }
.form-l { background: #ef4444; }

/* Legenda stipjes */
.legend-dot {
  display: inline-block; width: 10px; height: 10px; border-radius: 50%;
  margin-right: 4px; vertical-align: middle;
}

/* Save export/import textarea */
.save-area {
  width: 100%;
  min-height: 90px;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-body);
  color: var(--text-muted);
  font-family: monospace;
  font-size: 11px;
  resize: vertical;
  word-break: break-all;
}

/* Chips */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { padding: 6px 12px; border-radius: 20px; background: var(--bg-body); cursor: pointer; border: 1px solid var(--border); }
.chip.active { background: var(--accent); color: #06250f; border-color: var(--accent); font-weight: bold; }

/* TOAST */
.toast {
  position: fixed; bottom: 30px; right: 30px;
  background: var(--accent); color: #06250f;
  padding: 12px 20px; border-radius: 8px; font-weight: bold;
  opacity: 0; pointer-events: none; transition: 0.3s; transform: translateY(10px);
  z-index: 2000;
}
.toast.show { opacity: 1; transform: translateY(0); }

/* STAND KLEUREN */
tr.promo { background: linear-gradient(90deg, rgba(34,197,94,0.15) 0%, transparent 100%); border-left: 4px solid #22c55e; }
tr.rele { background: linear-gradient(90deg, rgba(239,68,68,0.15) 0%, transparent 100%); border-left: 4px solid #ef4444; }
tr.my-club { font-weight: bold; background: rgba(34, 197, 94, 0.12) !important; outline: 1px solid var(--accent); outline-offset: -1px; }

/* FACILITEITEN */
.facilities-grid {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.facility-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.level-dots {
  display: flex;
  gap: 4px;
  margin-bottom: 14px;
}

.level-dot {
  width: 16px;
  height: 6px;
  border-radius: 3px;
  background: var(--border);
}

.level-dot.filled {
  background: var(--accent);
}

.impact-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.impact-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  gap: 10px;
}

.impact-row > span:first-child {
  flex-shrink: 0;
}

.impact-row > div {
  text-align: right;
  white-space: nowrap;
}

.impact-arrow {
  color: var(--text-muted);
  margin: 0 2px;
  font-size: 12px;
}

/* PITCH */
.pitch-container { position: relative; width: 100%; height: 440px; background: linear-gradient(180deg, #2f855a 0%, #276749 50%, #2f855a 100%); border-radius: 8px; margin-top: 20px; border: 2px solid rgba(255,255,255,0.4); overflow: hidden; }
.pitch-line { position: absolute; background: rgba(255,255,255,0.3); }
.center-line { width: 2px; height: 100%; left: 50%; transform: translateX(-50%); }
.center-circle { width: 100px; height: 100px; border: 2px solid rgba(255,255,255,0.3); border-radius: 50%; top: 50%; left: 50%; transform: translate(-50%, -50%); background: transparent !important; }
.box-top { width: 60%; height: 60px; top: 0; left: 20%; border: 2px solid rgba(255,255,255,0.3); border-top: none; background: transparent !important; }
.box-bottom { width: 60%; height: 60px; bottom: 0; left: 20%; border: 2px solid rgba(255,255,255,0.3); border-bottom: none; background: transparent !important; }

.player-node { position: absolute; transform: translate(-50%, -50%); text-align: center; cursor: pointer; transition: 0.2s; width: 60px; }
.player-node:hover { transform: translate(-50%, -50%) scale(1.1); z-index: 10; }
.shirt { width: 30px; height: 30px; background: #ef4444; border-radius: 50%; margin: 0 auto; line-height: 30px; color: white; font-weight: bold; font-size: 12px; border: 2px solid white; }
.shirt.gk { background: #eab308; }
.shirt.empty { background: #333; border: 2px dashed #666; color: #666; }
.player-info { font-size: 10px; background: rgba(0,0,0,0.7); padding: 2px 4px; border-radius: 4px; margin-top: 2px; color: white; white-space: nowrap; }

/* MODAL */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.7); display: flex; align-items: center; justify-content: center; z-index: 3000; }
.modal-content { background: var(--bg-card); padding: 20px; border-radius: 12px; width: 90%; max-width: 500px; border: 1px solid var(--border); max-height: 80vh; overflow-y: auto; }
.modal-body { line-height: 1.5; }
.modal-input {
  width: 100%;
  margin-top: 15px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-body);
  color: var(--text-main);
  font-size: 16px;
  font-family: var(--font-family);
}
.modal-input:focus { outline: 2px solid var(--accent); border-color: var(--accent); }

/* "MEER" MENU (mobiel) */
.more-menu-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.more-menu-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 12px 5px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--border);
  background: var(--bg-body);
}
.more-menu-item span { font-size: 22px; }
.more-menu-item.active { background: var(--accent); color: #06250f; font-weight: 700; }

/* "Meer" knop alleen op mobiel */
.nav-item.nav-more { display: none; }

/* --- LIVE WEDSTRIJD --- */
.live-box { max-width: 560px; }

.live-competition {
  text-align: center;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.live-scoreboard {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 15px;
  background: var(--bg-body);
  border-radius: 10px;
  border: 1px solid var(--border);
}

.live-team {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.live-team-name {
  font-weight: 700;
  font-size: 13px;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.live-score {
  font-size: 34px;
  font-weight: 800;
  color: var(--accent);
  flex-shrink: 0;
  min-width: 90px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.live-clock-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 14px 0 10px;
}

.live-minute {
  font-weight: 800;
  font-size: 15px;
  min-width: 78px;
  font-variant-numeric: tabular-nums;
}

.live-progress {
  flex: 1;
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.live-progress-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.15s linear;
}

.live-feed {
  min-height: 140px;
  max-height: 220px;
  overflow-y: auto;
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.live-event {
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 6px;
  background: rgba(128,128,128,0.08);
  animation: live-pop 0.25s ease-out;
}

.live-event-goal { background: rgba(34,197,94,0.15); border-left: 3px solid #22c55e; font-weight: 600; }
.live-event-red { background: rgba(239,68,68,0.15); border-left: 3px solid #ef4444; }
.live-event-injury { background: rgba(234,179,8,0.12); border-left: 3px solid #eab308; }
.live-note { background: rgba(251,191,36,0.1); color: #fbbf24; font-size: 12px; }
.live-kickoff { font-size: 12px; color: var(--text-muted); text-align: center; padding: 6px; }

@keyframes live-pop {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; border-bottom: 1px solid var(--border); padding-bottom: 10px; }
.modal-footer { margin-top: 20px; text-align: right; display: flex; justify-content: flex-end; gap: 10px; }
.player-select-row { display: flex; justify-content: space-between; padding: 8px; border-bottom: 1px dashed var(--border); cursor: pointer; }
.player-select-row:hover { background: rgba(255,255,255,0.05); }
.player-select-row.disabled { opacity: 0.5; pointer-events: none; }

/* --- VISUALS --- */

/* Club Badge */
.club-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%; /* Rondje */
  color: #fff;
  font-weight: 800;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
  border: 2px solid rgba(255,255,255,0.2);
  flex-shrink: 0;
  user-select: none;
}

/* Flexbox helper voor tabellen (Badge + Naam) */
.club-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Player Face */
.player-face {
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.1);
  position: relative;
  display: inline-block;
  overflow: hidden;
  flex-shrink: 0;
}
.player-eyes {
  position: absolute;
  top: 35%; left: 20%;
  width: 60%; height: 10%;
  display: flex; justify-content: space-between;
}
.player-eyes::before, .player-eyes::after {
  content:''; width: 30%; height: 100%; background: #333; border-radius: 50%; display:block;
}
.player-mouth {
  position: absolute;
  bottom: 25%; left: 35%;
  width: 30%; height: 5%;
  background: rgba(0,0,0,0.2);
  border-radius: 10px;
}

/* --- MOBILE RESPONSIVENESS (Dit vervangt je oude blok) --- */
@media (max-width: 768px) {

  /* 1. Layout draaien */
  .app-layout {
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
  }

  /* 2. Sidebar wordt Bottom Navigation Bar */
  .sidebar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 65px;         /* Vaste hoogte */
    border-right: none;
    border-top: 1px solid var(--border);
    background: var(--bg-sidebar);
    z-index: 1000;
    
    /* Reset desktop stijlen */
    padding: 0;
    display: flex;
    flex-direction: row;  /* Horizontaal */
    align-items: center;
    
    /* Scrollen instellen voor mobiel */
    overflow-y: hidden;
    overflow-x: auto;     /* Horizontaal swipen */
  }

  /* Verberg Logo en Footer (Koffie) op mobiel om ruimte te maken */
  .sidebar .brand, 
  .sidebar .sidebar-footer {
    display: none;
  }

  /* 3. Menu Items horizontaal maken: alleen de 4 hoofd-tabs + "Meer" */
  .nav-links {
    flex-direction: row;
    width: 100%;
    margin: 0;
    padding: 0 10px;
    gap: 5px;
    overflow: hidden;
  }

  .nav-item.nav-secondary { display: none; }
  .nav-item.nav-more { display: flex; }

  .nav-item {
    min-width: 60px;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 5px 0;
    font-size: 10px;
    text-align: center;
    border-radius: 4px;
  }

  .nav-item span {
    margin-right: 0 !important; /* Icoon boven tekst */
    font-size: 20px;
    margin-bottom: 2px;
  }

  /* 4. Main Content aanpassen */
  .main-content {
    height: 100%;
    overflow-y: auto;           /* Inhoud moet scrollen */
    padding-bottom: 80px;       /* Extra ruimte onderin voor de balk */
  }

  .view-container {
    padding: 15px;
  }

  /* 5. Header compacter maken */
  .top-header {
    height: auto;
    padding: 15px;
    flex-direction: column;     /* Onder elkaar */
    gap: 15px;
  }

  .stats-group {
    width: 100%;
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
  }

  .stat-item .label { font-size: 9px; }
  .stat-item strong { font-size: 14px; }

  .actions-group {
    width: 100%;
    display: flex;
    gap: 10px;
  }

  .actions-group button {
    flex: 1;                    /* Knoppen vullen de breedte */
    padding: 12px;              /* Makkelijker te raken */
  }

  /* 6. Tabellen fixen op mobiel */
  .card {
    overflow-x: auto;
    margin-bottom: 15px;
  }
  
  table {
    min-width: 600px;           /* Forceer breedte zodat je kunt scrollen */
  }
  
  /* Veld iets kleiner */
  .pitch-container {
    zoom: 0.7;
  }

  /* Progress Bar animatie */
  .progress-bar { transition: width 0.5s ease-in-out; }
}