/* ============================================================
   VARIABLES.CSS — Design tokens voor StatieGeld Teller
   Dark & Light mode + animaties
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600;700&family=DM+Mono:wght@400;500&display=swap');

:root {
  /* LIGHT MODE (standaard) */
  --bg:           #f0f4f8;
  --bg-2:         #e8edf4;
  --card:         #ffffff;
  --card-hover:   #f8fafc;
  --border:       #e2e8f0;
  --border-light: #cbd5e1;

  --teal:         #06b6d4;
  --teal-dark:    #0891b2;
  --teal-glow:    rgba(6, 182, 212, 0.1);
  --teal-glow-2:  rgba(6, 182, 212, 0.05);

  --green:        #22c55e;
  --green-bg:     rgba(34, 197, 94, 0.1);
  --red:          #ef4444;
  --red-bg:       rgba(239, 68, 68, 0.1);
  --orange:       #f97316;
  --yellow:       #eab308;

  --text:         #0f172a;
  --text-2:       #334155;
  --muted:        #94a3b8;
  --muted-light:  #64748b;

  --shadow:       0 4px 24px rgba(0,0,0,0.08);
  --shadow-sm:    0 2px 8px rgba(0,0,0,0.06);
  --shadow-teal:  0 4px 24px rgba(6,182,212,0.15);

  --radius:       12px;
  --radius-sm:    8px;
  --radius-lg:    16px;
  --radius-xl:    20px;

  --font:         'DM Sans', sans-serif;
  --font-mono:    'DM Mono', monospace;

  --nav-height:   60px;
  --bottom-nav:   64px;

  --transition:   all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  --spring:       cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* DARK MODE */
[data-theme="dark"] {
  --bg:           #0a0f1e;
  --bg-2:         #0f172a;
  --card:         #1a2235;
  --card-hover:   #1e2a3d;
  --border:       #2a3a52;
  --border-light: #334155;

  --text:         #f0f6ff;
  --text-2:       #cbd5e1;
  --muted:        #64748b;
  --muted-light:  #94a3b8;

  --shadow:       0 4px 24px rgba(0,0,0,0.4);
  --shadow-sm:    0 2px 8px rgba(0,0,0,0.3);
  --teal-glow:    rgba(6, 182, 212, 0.15);
  --teal-glow-2:  rgba(6, 182, 212, 0.08);
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
  transition: background 0.3s ease, color 0.3s ease;
}

/* Subtiele achtergrond texture */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 20% -10%, rgba(6,182,212,0.06) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 80% 110%, rgba(6,182,212,0.04) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ============================================================
   TYPOGRAPHY
   ============================================================ */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font);
  font-weight: 700;
  line-height: 1.2;
  color: var(--text);
}

h1 { font-size: clamp(1.5rem, 4vw, 2rem); }
h2 { font-size: clamp(1.2rem, 3vw, 1.5rem); }
h3 { font-size: 1.1rem; }

p { color: var(--text-2); }

a {
  color: var(--teal);
  text-decoration: none;
  transition: var(--transition);
}
a:hover { opacity: 0.8; }

/* ============================================================
   LAYOUT
   ============================================================ */
.page-wrap {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  padding-top: 20px;
  padding-bottom: calc(var(--bottom-nav) + 16px);
}

.container {
  max-width: 600px;
  margin: 0 auto;
  padding: 0 16px;
}

/* ============================================================
   NAVBAR (top)
   ============================================================ */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-height);
  background: rgba(240, 244, 248, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 8px;
  transition: background 0.3s ease;
}

[data-theme="dark"] .navbar {
  background: rgba(10, 15, 30, 0.85);
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  font-size: 17px;
  flex-shrink: 0;
}

.navbar-brand img {
  width: 28px;
  height: 28px;
  object-fit: contain;
  border-radius: 6px;
}

.navbar-center {
  display: none;
  align-items: center;
  gap: 4px;
  margin: 0 auto;
}

.nav-link {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  color: var(--muted-light);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: var(--transition);
}

.nav-link:hover {
  color: var(--text);
  background: var(--card);
}

.nav-link.active {
  color: var(--teal);
  background: var(--teal-glow);
}

.navbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
}

.navbar-actions::-webkit-scrollbar { display: none; }

/* ============================================================
   BOTTOM NAVIGATION
   ============================================================ */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: var(--bottom-nav);
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  /* FIX: één border-top, geen box-shadow die dubbele lijn geeft */
  border-top: 1px solid var(--border);
  box-shadow: none;
  display: flex;
  align-items: center;
  /* iPhone notch support */
  padding-bottom: env(safe-area-inset-bottom, 0);
}

[data-theme="dark"] .bottom-nav {
  background: rgba(10, 15, 30, 0.95);
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 8px 4px;
  color: var(--muted);
  text-decoration: none;
  font-size: 11px;
  font-weight: 500;
  transition: var(--transition);
  position: relative;
}

.bottom-nav-item .nav-icon {
  font-size: 20px;
  transition: transform 0.3s var(--spring);
}

.bottom-nav-item.active {
  color: var(--teal);
}

.bottom-nav-item.active .nav-icon {
  transform: translateY(-2px) scale(1.1);
}

.bottom-nav-item.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 32px;
  height: 2px;
  background: var(--teal);
  border-radius: 0 0 2px 2px;
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  transition: var(--transition);
}

.card:hover {
  border-color: var(--border-light);
}

.card-elevated {
  box-shadow: var(--shadow);
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  -webkit-appearance: none;
  text-decoration: none;
}

.btn:active {
  transform: scale(0.96);
}

.btn-primary {
  background: var(--teal);
  color: #fff;
}
.btn-primary:hover {
  background: var(--teal-dark);
  box-shadow: var(--shadow-teal);
}

.btn-secondary {
  background: var(--card);
  color: var(--text-2);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  background: var(--card-hover);
  border-color: var(--border-light);
  color: var(--text);
}

.btn-ghost {
  background: transparent;
  color: var(--muted-light);
  border: 1px solid var(--border);
  padding: 6px 10px;
  font-size: 12px;
}
.btn-ghost:hover {
  background: var(--card);
  color: var(--text);
}

.btn-danger {
  background: var(--red-bg);
  color: var(--red);
  border: 1px solid rgba(239,68,68,0.2);
}
.btn-danger:hover {
  background: var(--red);
  color: #fff;
}

.btn-full { width: 100%; }
.btn-lg { padding: 14px 20px; font-size: 15px; border-radius: var(--radius); }

/* ============================================================
   FORM ELEMENTS
   ============================================================ */
.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted-light);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 11px 14px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  outline: none;
  transition: var(--transition);
  -webkit-appearance: none;
}

.form-control:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px var(--teal-glow);
}

.form-control::placeholder { color: var(--muted); }

.input-wrap { position: relative; }
.input-wrap .form-control { padding-left: 38px; }
.input-wrap .input-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 15px;
  pointer-events: none;
}
.input-wrap .input-action {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
  font-size: 15px;
  transition: var(--transition);
}
.input-wrap .input-action:hover { color: var(--text); }

/* ============================================================
   BADGES & PILLS
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.badge-teal  { background: var(--teal-glow);  color: var(--teal); }
.badge-green { background: var(--green-bg);   color: var(--green); }
.badge-red   { background: var(--red-bg);     color: var(--red); }
.badge-muted { background: var(--border);     color: var(--muted-light); }

/* ============================================================
   ALERTS
   ============================================================ */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 16px;
  animation: slideDown 0.3s ease;
}

.alert-error   { background: var(--red-bg);   border: 1px solid rgba(239,68,68,0.25); color: #fca5a5; }
.alert-success { background: var(--green-bg); border: 1px solid rgba(34,197,94,0.25); color: #86efac; }
.alert-info    { background: var(--teal-glow); border: 1px solid rgba(6,182,212,0.25); color: var(--teal); }

/* ============================================================
   SUMMARY BAR
   ============================================================ */
.summary-bar {
  background: linear-gradient(135deg, var(--card) 0%, var(--card-hover) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin: 12px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.summary-total {
  font-size: 28px;
  font-weight: 700;
  color: var(--teal);
  font-family: var(--font-mono);
  letter-spacing: -0.02em;
  transition: var(--transition);
}

.summary-meta {
  font-size: 13px;
  color: var(--muted-light);
}

.summary-meta span {
  color: var(--text-2);
  font-weight: 600;
}

/* ============================================================
   COUNTER ROWS
   ============================================================ */
.counter-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  margin-bottom: 8px;
  transition: var(--transition);
  animation: fadeInUp 0.3s ease both;
}

.counter-item:hover {
  border-color: var(--border-light);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.counter-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.counter-item-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.counter-item-price {
  font-size: 13px;
  color: var(--muted-light);
  font-family: var(--font-mono);
}

.counter-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.counter-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: var(--transition);
  -webkit-appearance: none;
  white-space: nowrap;
}

.counter-btn:hover {
  background: var(--card-hover);
  border-color: var(--border-light);
  color: var(--text);
}

.counter-btn.btn-add:hover {
  background: var(--teal-glow);
  border-color: var(--teal);
  color: var(--teal);
}

.counter-btn.btn-sub:hover {
  background: var(--red-bg);
  border-color: rgba(239,68,68,0.3);
  color: var(--red);
}

.counter-btn:active {
  transform: scale(0.92);
}

/* Teller display */
.counter-display {
  min-width: 44px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--teal-glow);
  border: 1px solid rgba(6,182,212,0.3);
  border-radius: var(--radius-sm);
  color: var(--teal);
  font-size: 16px;
  font-weight: 700;
  font-family: var(--font-mono);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.counter-display.bump {
  animation: bump 0.25s var(--spring);
}

.counter-delete {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  transition: var(--transition);
  margin-left: 4px;
  flex-shrink: 0;
}

.counter-delete:hover {
  color: var(--red);
  background: var(--red-bg);
}

/* ============================================================
   ADD ITEM PANEL
   ============================================================ */
.add-panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 12px;
  overflow: hidden;
  transition: var(--transition);
}

.add-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  cursor: pointer;
  user-select: none;
}

.add-panel-header:hover { background: var(--card-hover); }

.add-panel-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 14px;
}

.add-panel-toggle {
  color: var(--muted);
  font-size: 18px;
  transition: transform 0.3s ease;
}

.add-panel.open .add-panel-toggle {
  transform: rotate(180deg);
}

.add-panel-body {
  padding: 0 16px 16px;
  display: none;
  animation: fadeIn 0.2s ease;
}

.add-panel.open .add-panel-body { display: block; }

.add-panel-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}

/* ============================================================
   STATS CARDS
   ============================================================ */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
  animation: fadeInUp 0.3s ease both;
}

.stat-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.stat-value {
  font-size: 24px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text);
}

.stat-value.teal { color: var(--teal); }
.stat-value.green { color: var(--green); }

/* ============================================================
   TOGGLE SWITCH
   ============================================================ */
.toggle {
  position: relative;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.toggle input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 24px;
  cursor: pointer;
  transition: var(--transition);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  background: white;
  border-radius: 50%;
  transition: var(--transition);
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.toggle input:checked + .toggle-slider { background: var(--teal); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); }

/* ============================================================
   SECTION HEADERS
   ============================================================ */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding-top: 8px;
}

.section-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
.toast-container {
  position: fixed;
  bottom: calc(var(--bottom-nav) + 16px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  box-shadow: var(--shadow);
  white-space: nowrap;
  animation: toastIn 0.3s var(--spring) both;
  pointer-events: auto;
}

.toast.toast-success { border-color: rgba(34,197,94,0.3); color: var(--green); }
.toast.toast-error   { border-color: rgba(239,68,68,0.3); color: var(--red); }
.toast.toast-info    { border-color: rgba(6,182,212,0.3); color: var(--teal); }

/* Lijst teller label in knop */
.list-count-label {
  font-size: 11px;
  font-weight: 600;
  opacity: 0.65;
  margin-left: 2px;
}
.toast.hiding        { animation: toastOut 0.2s ease both; }

/* ============================================================
   LOADING STATES
   ============================================================ */
.skeleton {
  background: linear-gradient(90deg, var(--card) 25%, var(--card-hover) 50%, var(--card) 75%);
  background-size: 200% 100%;
  animation: skeleton 1.5s infinite;
  border-radius: var(--radius-sm);
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

/* ============================================================
   DIVIDER
   ============================================================ */
.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  color: var(--muted);
  font-size: 12px;
}
.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ============================================================
   KEYFRAME ANIMATIES
   ============================================================ */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes bump {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.2); }
  100% { transform: scale(1); }
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px) scale(0.9); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to   { opacity: 0; transform: translateY(-8px) scale(0.9); }
}

@keyframes skeleton {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

/* Staggered list animaties */
.counter-item:nth-child(1) { animation-delay: 0.05s; }
.counter-item:nth-child(2) { animation-delay: 0.10s; }
.counter-item:nth-child(3) { animation-delay: 0.15s; }
.counter-item:nth-child(4) { animation-delay: 0.20s; }
.counter-item:nth-child(5) { animation-delay: 0.25s; }
.counter-item:nth-child(6) { animation-delay: 0.30s; }

/* ============================================================
   RESPONSIVE — Desktop
   ============================================================ */
@media (min-width: 768px) {
  :root { --nav-height: 64px; }

  .page-wrap { padding-bottom: 0; }
  .bottom-nav { display: none; }

  .container {
    max-width: 900px;
    padding: 0 24px;
  }

  .add-panel-grid {
    grid-template-columns: 2fr 1fr 1fr 1fr auto;
  }

  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .navbar-brand span { font-size: 18px; }

  .navbar-center { display: flex; }
}
