@import url('https://fonts.googleapis.com/css2?family=Barlow+Condensed:wght@500;600;700;800&family=Inter:wght@400;500;600;700&display=swap');

:root {
  /* Color — neutrals zijn voor alle themes hetzelfde */
  --bg: #0a0d10;
  --bg-soft: #131820;
  --panel: #181d24;
  --panel-hi: #232932;
  --border: #232a33;
  --border-hi: #353d49;
  --ink: #ffffff;
  --muted: #8b95a3;
  --muted-hi: #b8c1ce;
  --them: #ff6b54;
  --green: #4ade80;

  /* Accent — wordt per theme overgenomen */
  --ball: #c4ff00;
  --ball-dim: #9bcc00;
  --ball-bright: #d4ff33;
  --ball-glow: rgba(196,255,0,.35);
  --ball-soft: rgba(196,255,0,.08);

  /* Spacing scale */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --sp-7: 48px;
  --sp-8: 64px;

  /* Radius */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;
  --r-full: 999px;
}
html[data-theme="ice"] {
  --ball: #00d4ff;
  --ball-dim: #00a3cc;
  --ball-bright: #33dfff;
  --ball-glow: rgba(0,212,255,.4);
  --ball-soft: rgba(0,212,255,.08);
}
html[data-theme="sunset"] {
  --ball: #ff9533;
  --ball-dim: #cc6600;
  --ball-bright: #ffa84d;
  --ball-glow: rgba(255,149,51,.4);
  --ball-soft: rgba(255,149,51,.1);
}
html[data-theme="mono"] {
  --ball: #ffffff;
  --ball-dim: #cccccc;
  --ball-bright: #ffffff;
  --ball-glow: rgba(255,255,255,.18);
  --ball-soft: rgba(255,255,255,.06);
}
html[data-theme="court"] {
  --ball: #4ade80;
  --ball-dim: #339966;
  --ball-bright: #65e89c;
  --ball-glow: rgba(74,222,128,.4);
  --ball-soft: rgba(74,222,128,.08);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
*:focus { outline: none; }
*::selection { background: var(--ball); color: #0a0d10; }

html { font-size: 16px; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background-color: var(--user-bg, var(--bg));
  background-image: var(--user-bg-image,
    radial-gradient(ellipse 80% 60% at 50% 0%, var(--ball-soft), transparent 60%)
  );
  color: var(--ink);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--sp-6) var(--sp-4);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  line-height: 1.5;
}

.wrap { max-width: 440px; width: 100%; }
.wrap-wide { max-width: 640px; width: 100%; }

/* ---- Brand ---- */
.brand { text-align: center; margin-bottom: var(--sp-6); }
.brand-logo {
  display: inline-block; width: 64px; height: 64px;
  background-image: url('/img/logo.png');
  background-size: cover; background-position: center;
  border-radius: var(--r-lg);
  box-shadow: 0 8px 32px var(--ball-soft);
}
.brand-name {
  font-family: 'Barlow Condensed', sans-serif; font-weight: 800;
  font-size: clamp(1.7rem, 5vw, 2.2rem); letter-spacing: -.01em;
  text-transform: uppercase; line-height: 1; margin-top: var(--sp-3);
}
.brand-name span { color: var(--ball); }
.brand-tagline {
  color: var(--muted); margin-top: var(--sp-2);
  font-size: .72rem; letter-spacing: .25em; text-transform: uppercase; font-weight: 500;
}

/* ---- Card ---- */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-6) var(--sp-5);
  box-shadow: 0 4px 32px rgba(0,0,0,.35);
}
.card + .card { margin-top: var(--sp-4); }
.card h1 {
  font-family: 'Barlow Condensed', sans-serif; font-weight: 700;
  font-size: 1.45rem; text-transform: uppercase; letter-spacing: .01em;
  margin-bottom: var(--sp-2); line-height: 1.1;
}
.card .sub {
  color: var(--muted-hi); font-size: .9rem; margin-bottom: var(--sp-5); line-height: 1.55;
}

/* ---- Inputs ---- */
label {
  display: block; color: var(--muted-hi); font-size: .75rem;
  text-transform: uppercase; letter-spacing: .12em; margin-bottom: var(--sp-2); font-weight: 600;
}
input[type=email], input[type=password], input[type=text], input[type=url], select {
  width: 100%; background: var(--bg-soft); color: var(--ink);
  border: 1px solid var(--border); border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-4); font-family: inherit; font-size: 1rem; line-height: 1.4;
  margin-bottom: var(--sp-4);
  transition: border-color .15s, box-shadow .15s, background .15s;
}
input:hover, select:hover { border-color: var(--border-hi); }
input:focus, select:focus {
  border-color: var(--ball); background: var(--panel);
  box-shadow: 0 0 0 4px var(--ball-soft);
}
input::placeholder { color: #4a5663; }

/* ---- Buttons ---- */
.btn {
  width: 100%; background: var(--ball); color: #0a0d10; border: none;
  border-radius: var(--r-md);
  font-family: 'Barlow Condensed', sans-serif; font-weight: 700; font-size: 1.05rem;
  letter-spacing: .04em; text-transform: uppercase;
  padding: var(--sp-4) var(--sp-5); cursor: pointer; line-height: 1;
  box-shadow: 0 1px 0 rgba(255,255,255,.18) inset, 0 4px 16px var(--ball-soft);
  transition: transform .15s ease, box-shadow .2s ease, background .2s ease;
}
.btn:hover {
  transform: translateY(-2px);
  background: var(--ball-bright);
  box-shadow: 0 1px 0 rgba(255,255,255,.22) inset, 0 12px 32px var(--ball-glow);
}
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none; box-shadow: none; }
.btn.secondary {
  background: var(--panel); color: var(--ink);
  border: 1px solid var(--border-hi); box-shadow: none;
}
.btn.secondary:hover {
  background: var(--panel-hi); border-color: var(--ball); color: var(--ball);
  transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,.4);
}
.btn.danger {
  background: transparent; color: var(--them);
  border: 1px solid var(--them); box-shadow: none;
}
.btn.danger:hover { background: var(--them); color: #0a0d10; box-shadow: 0 6px 20px rgba(255,107,84,.25); }
.btn + .btn { margin-top: var(--sp-3); }

/* ---- Links ---- */
.link-row {
  text-align: center; color: var(--muted); font-size: .9rem;
  margin-top: var(--sp-5);
}
.link-row + .link-row { margin-top: var(--sp-3); }
.link-row a { color: var(--ball); text-decoration: none; font-weight: 600; transition: color .15s; }
.link-row a:hover { color: var(--ball-bright); }

/* ---- Feedback ---- */
.err { color: var(--them); font-size: .88rem; min-height: 1.2em; margin-top: var(--sp-3); }
.success { color: var(--green); font-size: .88rem; margin-top: var(--sp-3); }
.info {
  background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: var(--sp-4) var(--sp-4);
  color: var(--muted-hi); font-size: .88rem;
  margin-bottom: var(--sp-4); line-height: 1.55;
}
.info b { color: var(--ink); }

/* ---- Rows ---- */
.row {
  display: flex; justify-content: space-between; align-items: center; gap: var(--sp-4);
  padding: var(--sp-4) 0;
  border-bottom: 1px solid var(--border);
}
.row:first-child { padding-top: 0; }
.row:last-child { border-bottom: 0; padding-bottom: 0; }
.row-label {
  color: var(--muted); font-size: .72rem;
  text-transform: uppercase; letter-spacing: .14em; font-weight: 600;
}
.row-value { font-weight: 500; font-size: .95rem; }

/* ---- Sections ---- */
.section + .section { margin-top: var(--sp-6); }
.section h2 {
  font-family: 'Barlow Condensed', sans-serif; font-weight: 700; font-size: 1rem;
  text-transform: uppercase; letter-spacing: .08em; margin-bottom: var(--sp-4);
  color: var(--muted-hi);
}

/* ---- Status pills ---- */
.status-pill {
  display: inline-block; padding: var(--sp-1) var(--sp-3); border-radius: var(--r-full);
  font-size: .7rem; letter-spacing: .06em; text-transform: uppercase;
  border: 1px solid var(--border-hi); color: var(--muted-hi); font-weight: 600;
}
.status-pill.trial, .status-pill.active { color: var(--green); border-color: rgba(74,222,128,.4); background: rgba(74,222,128,.06); }
.status-pill.expired { color: var(--them); border-color: rgba(255,107,84,.4); background: rgba(255,107,84,.06); }

/* ---- PIN list ---- */
.pin-list { list-style: none; }
.pin-list li {
  background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: var(--sp-3) var(--sp-4); margin-bottom: var(--sp-3);
  display: flex; justify-content: space-between; align-items: center;
  transition: border-color .15s;
}
.pin-list li:hover { border-color: var(--border-hi); }
.pin-list .pin-val {
  font-family: 'Barlow Condensed', sans-serif; font-weight: 700;
  font-size: 1.3rem; letter-spacing: .14em;
}
.pin-list li button {
  background: transparent; border: none; color: var(--muted); cursor: pointer;
  font-family: inherit; font-size: .8rem; padding: var(--sp-1) var(--sp-2);
  border-radius: var(--r-sm); transition: color .15s, background .15s;
}
.pin-list li button:hover { color: var(--them); background: rgba(255,107,84,.08); }

.pin-input-row { display: flex; gap: var(--sp-2); align-items: flex-start; }
.pin-input-row input { flex: 1; margin-bottom: 0; }
.pin-input-row input.pin {
  text-align: center; letter-spacing: .25em;
  font-family: 'Barlow Condensed', sans-serif; font-size: 1.2rem; font-weight: 700;
}
.pin-input-row button { width: auto; padding: var(--sp-4) var(--sp-5); white-space: nowrap; }

/* ---- Banners ---- */
.banner {
  background: var(--ball-soft); border: 1px solid var(--ball-glow); color: var(--ball);
  padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md); font-size: .88rem;
  margin-bottom: var(--sp-4);
}
.banner.err { background: rgba(255,107,84,.06); border-color: rgba(255,107,84,.3); color: var(--them); }
.banner.success { background: rgba(74,222,128,.06); border-color: rgba(74,222,128,.3); color: var(--green); }

/* ---- Avatar ---- */
.avatar {
  width: 80px; height: 80px; border-radius: 50%;
  background: var(--bg-soft); border: 1px solid var(--border-hi);
  background-size: cover; background-position: center;
  display: inline-block;
}
.avatar.lg { width: 88px; height: 88px; }
.avatar.sm { width: 36px; height: 36px; }

/* ---- Stats grid ---- */
.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: var(--sp-3);
}
.stat-tile {
  background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: var(--sp-4); text-align: center;
  transition: border-color .15s, transform .15s;
}
.stat-tile:hover { border-color: var(--border-hi); transform: translateY(-2px); }
.stat-tile .num {
  font-family: 'Barlow Condensed', sans-serif; font-weight: 700;
  font-size: 1.7rem; line-height: 1; color: var(--ink);
}
.stat-tile .num.accent { color: var(--ball); }
.stat-tile .lbl {
  color: var(--muted); font-size: .68rem; margin-top: var(--sp-2);
  text-transform: uppercase; letter-spacing: .12em; font-weight: 600;
}

/* ---- Subnav ---- */
.subnav {
  display: flex; gap: var(--sp-2); margin-bottom: var(--sp-5); flex-wrap: wrap; align-items: center;
}
.subnav a {
  color: var(--muted-hi); text-decoration: none; font-size: .88rem; font-weight: 500;
  padding: var(--sp-2) var(--sp-4); border-radius: var(--r-full);
  border: 1px solid transparent; background: transparent;
  transition: all .15s;
}
.subnav a:hover { color: var(--ink); background: var(--panel); }
.subnav a.active {
  color: #0a0d10; background: var(--ball); font-weight: 700;
  box-shadow: 0 4px 16px var(--ball-glow);
}

/* ---- Animations ---- */
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
.wrap, .wrap-wide { animation: rise .3s ease both; }

/* ---- Loading / hidden ---- */
.loading { color: var(--muted); padding: var(--sp-7) 0; text-align: center; font-size: .9rem; }
.hidden { display: none !important; }

/* ---- Skeleton loaders ---- */
.skeleton {
  background: linear-gradient(90deg, var(--bg-soft) 0%, var(--panel-hi) 50%, var(--bg-soft) 100%);
  background-size: 200% 100%;
  border-radius: var(--r-sm);
  animation: shimmer 1.6s ease-in-out infinite;
  display: inline-block; line-height: 1;
}
.skeleton-text { height: 12px; width: 100%; }
.skeleton-text.sm { height: 10px; width: 60%; }
.skeleton-text.lg { height: 22px; width: 70%; }
.skeleton-text.xl { height: 28px; width: 50%; }
.skeleton-circle { width: 88px; height: 88px; border-radius: 50%; }
.skeleton-tile {
  height: 84px; width: 100%; border-radius: var(--r-md);
  background: linear-gradient(90deg, var(--bg-soft) 0%, var(--panel-hi) 50%, var(--bg-soft) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.6s ease-in-out infinite;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ---- Button loading ---- */
.btn[data-loading="1"] {
  position: relative; color: transparent !important;
  pointer-events: none;
}
.btn[data-loading="1"]::after {
  content: ''; position: absolute; left: 50%; top: 50%;
  margin: -9px 0 0 -9px;
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid currentColor; border-top-color: transparent;
  color: #0a0d10;
  animation: spin .7s linear infinite;
}
.btn.secondary[data-loading="1"]::after { color: var(--ink); }
.btn.danger[data-loading="1"]::after { color: var(--them); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Confirm modal ---- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 10000;
  background: rgba(0,0,0,.75); backdrop-filter: blur(8px);
  display: none; align-items: center; justify-content: center;
  padding: var(--sp-4); opacity: 0; transition: opacity .2s;
}
.modal-overlay.show { display: flex; opacity: 1; }
.modal-card {
  background: var(--panel); border: 1px solid var(--border-hi); border-radius: var(--r-lg);
  padding: var(--sp-6); max-width: 400px; width: 100%;
  box-shadow: 0 24px 80px rgba(0,0,0,.6);
  transform: scale(.94); transition: transform .2s;
}
.modal-overlay.show .modal-card { transform: none; }
.modal-card h3 {
  font-family: 'Barlow Condensed', sans-serif; font-weight: 700;
  font-size: 1.35rem; text-transform: uppercase; letter-spacing: .02em;
  margin-bottom: var(--sp-3); line-height: 1.1;
}
.modal-card p { color: var(--muted-hi); font-size: .92rem; margin-bottom: var(--sp-5); line-height: 1.55; }
.modal-actions { display: flex; gap: var(--sp-3); }
.modal-actions .btn { flex: 1; padding: var(--sp-3) var(--sp-4); font-size: .95rem; }

/* ---- Toasts ---- */
.toast-container {
  position: fixed; bottom: var(--sp-4); left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: var(--sp-2); align-items: center;
  z-index: 9999; max-width: 92vw; pointer-events: none;
}
.toast {
  background: var(--panel); color: var(--ink);
  border: 1px solid var(--border-hi); border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-4); font-size: .9rem; min-width: 240px;
  box-shadow: 0 12px 40px rgba(0,0,0,.5);
  opacity: 0; transform: translateY(20px) scale(.95);
  transition: opacity .25s ease, transform .25s ease;
  pointer-events: auto; max-width: 100%;
  display: flex; align-items: center; gap: var(--sp-3);
  font-weight: 500;
}
.toast.show { opacity: 1; transform: none; }
.toast::before {
  content: ''; width: 7px; height: 7px; border-radius: 50%;
  background: currentColor; flex-shrink: 0; box-shadow: 0 0 8px currentColor;
}
.toast.toast-success { color: var(--green); border-color: rgba(74,222,128,.4); background: rgba(74,222,128,.08); }
.toast.toast-err { color: var(--them); border-color: rgba(255,107,84,.4); background: rgba(255,107,84,.08); }
.toast.toast-info { color: var(--ball); border-color: var(--ball-glow); background: var(--ball-soft); }

/* ---- Toggle switch ---- */
.toggle {
  display: inline-flex; align-items: center;
  width: 44px; height: 24px; position: relative;
  cursor: pointer; vertical-align: middle;
}
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0;
  background: var(--bg-soft); border: 1px solid var(--border-hi);
  border-radius: 100px; transition: background .2s, border-color .2s;
}
.toggle-slider::before {
  content: ''; position: absolute; left: 2px; top: 2px;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--muted);
  transition: transform .2s, background .2s;
}
.toggle input:checked + .toggle-slider {
  background: var(--ball-soft); border-color: var(--ball);
}
.toggle input:checked + .toggle-slider::before {
  transform: translateX(20px); background: var(--ball);
}

/* ---- Theme picker — minimal row van swatches ---- */
.theme-picker {
  display: flex; flex-wrap: wrap; gap: var(--sp-2);
}
.theme-swatch {
  position: relative; cursor: pointer;
  display: inline-flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-4) var(--sp-2) var(--sp-2);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  background: transparent;
  transition: border-color .15s, background .15s;
}
.theme-swatch:hover { border-color: var(--border-hi); background: var(--bg-soft); }
.theme-swatch.active {
  border-color: var(--ink); background: var(--bg-soft);
}
.theme-swatch-circle {
  width: 18px; height: 18px; border-radius: 50%;
  display: inline-block; flex-shrink: 0;
}
.theme-swatch-name {
  font-size: .8rem; color: var(--muted-hi); font-weight: 500;
}
.theme-swatch.active .theme-swatch-name { color: var(--ink); }
.theme-swatch.active .theme-swatch-circle {
  box-shadow: 0 0 0 2px var(--bg-soft), 0 0 0 4px currentColor;
}

/* ---- Footer ---- */
.app-footer {
  margin-top: auto; padding-top: var(--sp-6); text-align: center;
  color: var(--muted); font-size: .78rem; padding-bottom: var(--sp-4);
  width: 100%;
}
.app-footer a {
  color: var(--muted-hi); text-decoration: none; margin: 0 var(--sp-2);
  transition: color .15s;
}
.app-footer a:hover { color: var(--ball); }

/* ---- Mobile tweaks ---- */
@media (max-width: 480px) {
  body { padding: var(--sp-4) var(--sp-3); }
  .card { padding: var(--sp-5) var(--sp-4); }
  .brand-logo { width: 56px; height: 56px; }
  .brand-name { font-size: 1.6rem; }
  .pin-input-row { flex-direction: column; gap: var(--sp-3); }
  .pin-input-row input { width: 100%; }
  .pin-input-row button { width: 100%; }
}
