/* ── Reset & Base ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:           #0A0E1A;
  --bg-card:      #141824;
  --bg-card2:     #1E2435;
  --bg-input:     #1A1E2E;
  --border:       rgba(255,255,255,0.07);
  --text:         #E8ECF4;
  --text-muted:   #7A849A;
  --text-dim:     #4A5468;
  --accent:       #5865F2;
  --accent-glow:  rgba(88,101,242,0.35);
  --success:      #00E676;
  --success-glow: rgba(0,230,118,0.25);
  --danger:       #FF5252;
  --radius:       20px;
  --radius-sm:    12px;
  --shadow:       0 8px 32px rgba(0,0,0,0.5);
  --shadow-sm:    0 4px 16px rgba(0,0,0,0.3);
  --header-h:     62px;
  --nav-h:        52px;
  --transition:   0.2s ease;
}

[data-theme="light"] {
  --bg:           #F0F3FB;
  --bg-card:      #FFFFFF;
  --bg-card2:     #EEF1FA;
  --bg-input:     #F4F6FF;
  --border:       rgba(0,0,0,0.07);
  --text:         #1A1E2E;
  --text-muted:   #6B7280;
  --text-dim:     #A0A8B8;
  --accent:       #5865F2;
  --accent-glow:  rgba(88,101,242,0.18);
  --success:      #00C853;
  --success-glow: rgba(0,200,83,0.18);
  --danger:       #F44336;
  --shadow:       0 8px 32px rgba(0,0,0,0.1);
  --shadow-sm:    0 4px 16px rgba(0,0,0,0.06);
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

/* ── Layout ────────────────────────────────────────────────────────────────── */
#app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 100;
  backdrop-filter: blur(12px);
}

.tab-nav {
  position: fixed;
  top: var(--header-h);
  left: 0; right: 0;
  height: var(--nav-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 4px;
  z-index: 99;
}

#app-main {
  position: fixed;
  top: calc(var(--header-h) + var(--nav-h));
  left: 0; right: 0; bottom: 0;
  overflow: hidden;
}

.tab-content {
  display: none;
  height: 100%;
  overflow-y: auto;
  padding: 20px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.tab-content.active { display: flex; flex-direction: column; gap: 16px; }

/* ── Header ────────────────────────────────────────────────────────────────── */
.logo {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, var(--accent), #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.user-switcher {
  display: flex;
  align-items: center;
  gap: 8px;
}

#userSelect {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  min-width: 140px;
  font-family: inherit;
}
#userSelect:focus { border-color: var(--accent); }

.btn-icon {
  background: var(--bg-card2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  width: 36px; height: 36px;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  font-family: inherit;
}
.btn-icon:hover { background: var(--accent); border-color: var(--accent); color: #fff; transform: scale(1.05); }

.theme-toggle { font-size: 20px; }

/* ── Tab Nav ───────────────────────────────────────────────────────────────── */
.tab-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
  white-space: nowrap;
}
.tab-btn:hover { color: var(--text); background: var(--bg-card2); }
.tab-btn.active {
  color: var(--accent);
  background: var(--accent-glow);
}

/* ── Vandaag Tab ───────────────────────────────────────────────────────────── */
.today-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}
.today-date {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.5px;
}
.today-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Date navigator */
.date-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}
.date-nav-center {
  min-width: 180px;
}
.date-nav-btn {
  font-size: 22px;
  font-weight: 300;
  line-height: 1;
}
.date-nav-btn:disabled {
  opacity: 0.25;
  pointer-events: none;
}
.today-btn {
  padding: 7px 14px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}

.streak-badge {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 40px;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 700;
}
.streak-fire { font-size: 20px; }
.streak-label { color: var(--text-muted); font-weight: 500; font-size: 12px; }

/* Activity buttons grid */
.activity-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  flex-shrink: 0;
}

.activity-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 28px 16px;
  border-radius: var(--radius);
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  background: var(--bg-card);
  min-height: 150px;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.activity-btn:active { transform: scale(0.96) !important; }

.activity-btn .act-icon {
  font-size: 44px;
  line-height: 1;
  transition: transform 0.2s ease;
}
.activity-btn .act-name {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.2px;
  color: var(--text);
}
.activity-btn .act-duration {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}
.activity-btn .act-check {
  position: absolute;
  top: 12px;
  right: 14px;
  font-size: 18px;
  opacity: 0;
  transition: opacity 0.2s ease;
}

/* Color tint via pseudo-element — breed compatibel, geen color-mix nodig */
.activity-btn {
  color: var(--text);
  border-color: rgba(255,255,255,0.1);
  background: var(--bg-card);
}
[data-theme="light"] .activity-btn { border-color: rgba(0,0,0,0.08); }
.activity-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: calc(var(--radius) - 2px);
  background: var(--c, var(--accent));
  opacity: 0.07;
  pointer-events: none;
  transition: opacity var(--transition);
}
.activity-btn:hover {
  transform: translateY(-4px) scale(1.02);
  border-color: var(--c, var(--accent));
  box-shadow: 0 8px 32px rgba(0,0,0,0.35);
}
.activity-btn:hover::before { opacity: 0.16; }
.activity-btn:hover .act-icon { transform: scale(1.15); }

.activity-btn.logged {
  border-color: var(--success);
  box-shadow: 0 0 24px var(--success-glow);
}
.activity-btn.logged .act-check { opacity: 1; }
.activity-btn.logged .act-icon { filter: drop-shadow(0 0 8px currentColor); }

/* Today log */
.today-log {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  flex: 1;
  min-height: 80px;
}
.today-log-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.log-entries {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.log-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 8px 5px 12px;
  border-radius: 30px;
  font-size: 13px;
  font-weight: 600;
  background: var(--bg-card2);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all var(--transition);
}
.log-chip:hover { border-color: var(--accent); }
.chip-body { flex: 1; cursor: pointer; }
.chip-body:hover { color: var(--accent); }
.chip-del {
  font-size: 10px;
  color: var(--text-dim);
  cursor: pointer;
  padding: 2px 5px;
  border-radius: 10px;
  transition: all var(--transition);
  line-height: 1.4;
}
.chip-del:hover { color: var(--danger); background: rgba(255,82,82,0.12); }
.log-empty { color: var(--text-muted); font-size: 13px; }

.btn-danger-outline {
  background: none;
  color: var(--danger);
  border: 1px solid var(--danger);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all var(--transition);
  margin-right: auto;
}
.btn-danger-outline:hover { background: var(--danger); color: #fff; }

/* ── Stats Tab ─────────────────────────────────────────────────────────────── */
.stats-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}
.period-selector {
  display: flex;
  gap: 4px;
  background: var(--bg-card);
  padding: 4px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.period-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 7px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}
.period-btn:hover { color: var(--text); }
.period-btn.active { background: var(--accent); color: #fff; }

.stats-total {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
  text-align: right;
}
.stats-total strong { color: var(--text); font-size: 20px; font-weight: 800; }
.stats-days { font-size: 12px; color: var(--text-muted); margin-top: 2px; font-weight: 500; }

.charts-grid {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 14px;
  flex: 1;
  min-height: 0;
}
.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}
.chart-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  flex-shrink: 0;
}
.chart-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
}
.chart-wrap canvas {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
}

/* ── Gewicht Tab ───────────────────────────────────────────────────────────── */
.weight-top { display: flex; flex-direction: column; gap: 12px; flex-shrink: 0; }

.weight-stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.weight-stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  text-align: center;
}
.weight-stat-card.accent { border-color: var(--accent); box-shadow: 0 0 20px var(--accent-glow); }
.weight-stat-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text-muted); margin-bottom: 6px; }
.weight-stat-value { font-size: 28px; font-weight: 900; letter-spacing: -1px; }

.weight-input-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.weight-input-row input[type="number"],
.weight-input-row input[type="date"] {
  flex: 1;
  min-width: 120px;
}

.weight-chart-card { flex: 1; min-height: 0; }

/* ── Beheer Tab ────────────────────────────────────────────────────────────── */
.beheer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  flex: 1;
  min-height: 0;
}
.beheer-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow: hidden;
}
.beheer-card h3 {
  font-size: 15px;
  font-weight: 700;
  flex-shrink: 0;
}
.beheer-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.beheer-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg-card2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  gap: 10px;
}
.beheer-item-left {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 600;
}
.type-dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}
.beheer-add-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
  flex-wrap: wrap;
}

/* ── Inputs & Buttons ─────────────────────────────────────────────────────── */
input[type="text"],
input[type="number"],
input[type="date"],
textarea {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition);
  width: 100%;
}
input:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
input::placeholder, textarea::placeholder { color: var(--text-dim); }
textarea { resize: none; }

/* Date input calendar icon color */
input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(0.6);
  cursor: pointer;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn-primary:hover { filter: brightness(1.15); transform: translateY(-1px); box-shadow: 0 4px 16px var(--accent-glow); }
.btn-primary:active { transform: scale(0.97); }

.btn-secondary {
  background: var(--bg-card2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }

.btn-ghost {
  background: none;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all var(--transition);
}
.btn-ghost:hover { color: var(--text); border-color: var(--text-muted); }

.btn-danger {
  background: none;
  color: var(--text-dim);
  border: none;
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 18px;
  cursor: pointer;
  transition: color var(--transition);
  line-height: 1;
  font-family: inherit;
}
.btn-danger:hover { color: var(--danger); }

/* ── Modal ─────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  backdrop-filter: blur(4px);
}
.modal-overlay.visible {
  opacity: 1;
  pointer-events: all;
}
.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  width: min(440px, 90vw);
  box-shadow: var(--shadow);
  transform: translateY(20px) scale(0.97);
  transition: transform 0.2s ease;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.modal-overlay.visible .modal-box {
  transform: translateY(0) scale(1);
}
.modal-icon { font-size: 48px; text-align: center; }
.modal-title { font-size: 22px; font-weight: 800; text-align: center; }
.modal-subtitle { text-align: center; color: var(--text-muted); font-size: 14px; }
.modal-field { display: flex; flex-direction: column; gap: 7px; }
.modal-field label { font-size: 13px; font-weight: 600; color: var(--text-muted); }
.optional { font-weight: 400; color: var(--text-dim); }
.modal-actions { display: flex; gap: 10px; }
.modal-actions .btn-primary { flex: 1; padding: 13px; font-size: 15px; }
.modal-actions .btn-ghost { padding: 13px 20px; }

/* ── Toast ─────────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--bg-card2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 24px;
  border-radius: 40px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow);
  z-index: 600;
  transition: transform 0.3s ease, opacity 0.3s ease;
  opacity: 0;
  pointer-events: none;
}
.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ── No User Overlay ───────────────────────────────────────────────────────── */
.no-user-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 400;
}
.no-user-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 48px 40px;
  text-align: center;
  width: min(420px, 90vw);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.no-user-box h2 { font-size: 24px; font-weight: 800; }
.no-user-box p  { color: var(--text-muted); font-size: 14px; }

/* ── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .activity-grid { grid-template-columns: repeat(2, 1fr); }
  .charts-grid { grid-template-columns: 1fr; }
  .beheer-grid { grid-template-columns: 1fr; }
  .weight-stats-row { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 480px) {
  .weight-stats-row { grid-template-columns: 1fr 1fr; }
  .weight-stats-row .weight-stat-card:last-child { grid-column: span 2; }
  #app-header { padding: 0 12px; }
  .tab-btn { padding: 8px 12px; font-size: 13px; }
}

/* ── Scrollbar ─────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ── Transitions ───────────────────────────────────────────────────────────── */
* { transition: background-color 0.25s ease, border-color 0.25s ease, color 0.25s ease; }
button, input, textarea, select { transition: all 0.15s ease; }
