/* ============================================================================
   Surfies – Core Dark App Styles (cleaned, structured, de-duped)
   ----------------------------------------------------------------------------
   Notes:
   - Consistent tokens & surfaces
   - Removed duplicate/overlapping selectors
   - Scoped sidebar-only .row to avoid conflict with generic .row in cards
   - Consolidated .card-head & .badges rules
   - Added --sidebar-w, --handle-w, --sidebar-gutter
   ============================================================================ */

/* Reset */
* { margin: 0; padding: 0; box-sizing: border-box; }

/* Tokens (dark) */
:root{
  /* Base palette */
  --bg: #0b1020;
  --panel: #101a34;
  --surface: #0f172a;        /* frequently used dark surface */
  --ink: #e6e9f2;
  --muted: #9aa3b2;
  --line: #22325a;
  --accent: #2b54b7;
  --ok: #10b981;
  --warn: #f59e0b;
  --danger: #ef4444;
  --chip: #0d162d;

  /* Layout vars */
  --sidebar-w: 320px;        /* default width; used on mobile handle */
  --handle-w: 28px;          /* breedte van het lipje/handle */
  --sidebar-gutter: 0px;     /* extra ruimte naast lipje in open sidebar */
}

/* Base */
html, body {
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
}

a { color: #cfe0ff; text-decoration: none; }
a:hover { opacity: .9; }

/* ============================================================================
   App Header + Page Wrapper
   ============================================================================ */
.mini-topbar{
  position: sticky; top: 0; z-index: 2000;
  display: flex; align-items: center; gap: .75rem;
  padding: .6rem .8rem; background: #0b1220; color: #e6efff;
  border-bottom: 1px solid #1f2a44;
}
.mini-topbar .backbtn{
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .45rem .7rem; border: 1px solid #2a3b63; border-radius: .6rem;
  background: var(--surface); color: #cfe0ff; cursor: pointer;
}
.mini-topbar .title{ font-weight: 700; font-size: 1rem; letter-spacing: .2px; }

.main-wrap{ min-height: 100dvh; background: #0a1020; color: #cfe0ff; }
.page-inner{ padding: 1rem .8rem 2rem; max-width: 1100px; margin: 0 auto; }

/* ============================================================================
   Alerts (toast)
   ============================================================================ */
.alert-container{
  position: fixed; right: 12px; top: 12px; z-index: 3000;
  display: flex; flex-direction: column; gap: .5rem;
}
.alert{
  display: flex; align-items: center; gap: .6rem; padding: .55rem .7rem;
  border-radius: .5rem; border: 1px solid #2a3b63; background: var(--surface);
  color: #cfe0ff; box-shadow: 0 6px 18px rgba(0,0,0,.35);
}
.alert-success{ border-color: #246b3f; }
.alert-error{ border-color: #7a2b2b; }
.alert .alert-close{ background: none; border: none; color: inherit; cursor: pointer; font-size: 1rem; }

/* ============================================================================
   Buttons (unified)
   ============================================================================ */
.btn{
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .55rem .75rem; border-radius: .6rem; border: 1px solid #2a3b63;
  background: var(--surface); color: #dbe3f7; cursor: pointer;
}
.btn:hover{ background: #111c33; }
.btn.primary{ border-color: #2b5cd6; background: #102152; }
.btn.ok{ border-color: #1f4b2e; background: #0d1c12; color: #bbf7d0; }
.btn.warn{ border-color: #4a3d1e; background: #1b1608; color: #fde68a; }
.btn.danger{ border-color: #4b1f1f; background: #1c0d0d; color: #fecaca; }
.btn.ghost{ background: var(--surface); }
.actions-row{ display: flex; gap: .6rem; margin: .6rem 0 1rem; }

/* ============================================================================
   Sections / Forms
   ============================================================================ */
.section{
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; margin: 12px 0; overflow: hidden;
}
.sec-h{ padding: 12px 14px; border-bottom: 1px solid var(--line); font-weight: 700; }
.sec-b{ padding: 14px; }

.row2{ display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 768px){ .row2{ grid-template-columns: 1fr; } }

.form-group{ display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
input[type="text"], input[type="email"], input[type="password"], select, textarea{
  border: 1px solid var(--line); background: #0c162f; color: var(--ink);
  border-radius: 8px; padding: 10px 12px;
}
.small{ color: var(--muted); font-size: 12px; }
.chk{
  display: flex; align-items: flex-start; gap: 10px; padding: 10px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface); margin-bottom: 10px;
}
.chk input{ margin-top: 3px; }

/* ============================================================================
   Cards / Grids (generic + devices)
   ============================================================================ */
.grid{ display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.card{ background: var(--surface); border: 1px solid #1f2a44; border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 10px; }

/* Consolidated card head + badges */
.card-head{
  display: flex; justify-content: space-between; gap: 8px; align-items: flex-start;
}
.card-head > div:first-child{ flex: 1; min-width: 0; }

.badges{ display: flex; gap: 6px; flex-wrap: wrap; align-items: center; flex-shrink: 0; }
.badge{
  display: inline-flex; align-items: center; line-height: 1; white-space: nowrap;
  padding: 4px 10px; border-radius: 999px; background: var(--chip);
  border: 1px solid var(--line); font-size: 11px; color: #c7d2fe;
}
.badge.ok{ color: #bbf7d0; border-color: #1f4b2e; background: #0f1a14; }
.badge.warn{ color: #fde68a; border-color: #4a3d1e; background: #1b1608; }
.badge.danger{ color: #fecaca; border-color: #4b1f1f; background: #1c0d0d; }

.rows{ display: grid; gap: 6px; }
.row{ display: flex; justify-content: space-between; border-bottom: 1px solid var(--line); padding-bottom: 6px; }
.row:last-child{ border-bottom: none; padding-bottom: 0; }

.empty{ background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 24px; text-align: center; margin-top: 10px; }
.empty .emoji{ font-size: 40px; margin-bottom: 8px; }

/* Device card actions */
.actions { display: flex; flex-wrap: wrap; gap: 6px 8px; }
.actions .btn { flex: 0 0 auto; }

/* ============================================================================
   Stats (mini)
   ============================================================================ */
.statbar{ display: grid; grid-template-columns: repeat(3,1fr); gap: .8rem; margin: .8rem 0 1rem; }
.stat{ background: var(--surface); border: 1px solid #1f2a44; border-radius: .7rem; padding: .8rem; text-align: center; }
.stat .n{ font-size: 1.3rem; font-weight: 800; }
.stat .l{ font-size: .8rem; color: #8da4d0; }
@media (max-width: 640px){ .statbar{ grid-template-columns: 1fr; } }

/* ============================================================================
   Groups Grid
   ============================================================================ */
.groups-grid{ display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: .8rem; }
.gcard{ background: var(--surface); border: 1px solid #1f2a44; border-left: 4px solid #2a3b63; border-radius: .7rem; padding: 1rem; }
.gcard.admin{ border-left-color: #eab308; }
.gcard h3{ margin: 0 0 .25rem; font-size: 1.05rem; }
.gdesc{ color: #9db2df; font-size: .9rem; min-height: 1.2em; }
.grow{ display: flex; gap: .6rem; align-items: center; margin: .8rem 0; }
.badge.admin{ background: #4b3a12; border-color: #7a5a15; }
.gstats{ display: flex; gap: 1rem; color: #9db2df; font-size: .9rem; border-top: 1px solid #1f2a44; border-bottom: 1px solid #1f2a44; padding: .6rem 0; margin: .6rem 0; }
.gactions{ display: flex; gap: .5rem; }
.gactions .btn{ flex: 1; justify-content: center; }

/* ============================================================================
   Modals (shared dark)
   ============================================================================ */
.modal{ position: fixed; inset: 0; display: none; align-items: center; justify-content: center; background: rgba(0,0,0,.45); backdrop-filter: blur(2px); z-index: 4000; }
.modal.open{ display: flex; }
.modal-content{ width: min(680px,92vw); max-height: calc(100vh - 32px); overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.modal-header, .modal-footer{ padding: 12px 14px; border-bottom: 1px solid var(--line); }
.modal-footer{ border-bottom: none; border-top: 1px solid var(--line); }
.modal-body{ padding: 14px; }
.modal-close{ font-size: 22px; background: transparent; border: none; color: #cfe0ff; cursor: pointer; }

/* groups.php modal details */
.modal-card{ width: min(720px,92vw); background: var(--surface); border: 1px solid #1f2a44; border-radius: .8rem; box-shadow: 0 24px 64px rgba(0,0,0,.55); }
.modal-hd{ display: flex; align-items: center; justify-content: space-between; padding: .8rem 1rem; border-bottom: 1px solid #1f2a44; }
.modal-bd{ padding: 1rem; }
.modal-ft{ display: flex; gap: .6rem; justify-content: flex-end; padding: .8rem 1rem; border-top: 1px solid #1f2a44; }
.xbtn{ background: none; border: 1px solid #2a3b63; color: #cfe0ff; border-radius: .5rem; padding: .25rem .5rem; cursor: pointer; }

.form-row{ display: flex; flex-direction: column; gap: .35rem; margin-bottom: .8rem; }
.form-row input, .form-row textarea{ background: #0b1220; border: 1px solid #2a3b63; color: #cfe0ff; border-radius: .45rem; padding: .55rem .6rem; }
.muted{ color: #9db2df; font-size: .9rem; }

/* ============================================================================
   MAP (map.php)
   - Sidebar, tabs, tiles, history, members, layout
   ============================================================================ */
.page{ position: relative; height: 100vh; width: 100vw; overflow: hidden; }

/* Sidebar */
.sidebar{
  position: absolute; left: 0; top: 0; bottom: 0; width: var(--sidebar-w);
  background: linear-gradient(180deg, #0c1326 0%, #0e1428 100%);
  border-right: 1px solid #1f2a44; padding: 12px; display: flex; flex-direction: column; gap: 10px; z-index: 1200;
}
.brand{ display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; padding: 6px 4px; margin: 0 2px 6px; }
.brand:hover{ opacity: .9; }
.brand-mark{ height: 34px; width: 34px; display: block; }
.brand-name{ font-size: 18px; font-weight: 900; line-height: 1; }

.section-title{ font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 6px 2px 2px; }

/* Tabs */
.tabs{ display: flex; gap: 0; margin: 6px 2px 8px; border-bottom: 1px solid #24304d; }
.tab{
  flex: 1; text-align: center; padding: 10px 12px; cursor: pointer; background: transparent; color: #94a3b8;
  border: none; border-bottom: 2px solid transparent; border-top-left-radius: 8px; border-top-right-radius: 8px; font-weight: 600;
}
.tab:hover{ background: var(--surface); color: #cfe0ff; }
.tab.active{ color: #fff; background: #101a34; border-bottom-color: var(--accent); }

/* Tiles in sidebar */
.tile{ background: var(--panel); border: 1px solid #24304d; padding: 10px; border-radius: 8px; }
.tile + .tile{ margin-top: 10px; }
.tile .title{ font-weight: 700; margin-bottom: 2px; }
.subline{ font-size: 13px; color: #dbe3f7; display: flex; align-items: center; gap: 8px; margin: 2px 0; }
.subline .disc{ width: 8px; height: 8px; border-radius: 50%; }
.disc.ok{ background: var(--ok); }
.disc.err{ background: var(--danger); }
.disc.muted{ background: #3c4a6d; }
.muteline{ font-size: 12px; color: var(--muted); margin-top: 2px; }
.sos{ color: var(--danger); font-weight: 700; margin-left: 6px; }

/* Sidebar internal rows/actions (scoped to avoid .row conflicts) */
.sidebar .row{ display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.sidebar .row-actions .btn{ flex: 1; text-align: center; }

/* Sidebar footer iconbar */
.sidebar-footer{ margin-top: auto; }
.iconbar{ display: flex; gap: 8px; margin: 6px 2px 2px; }
.iconbtn{ display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border: 1px solid #2a3b63; border-radius: 8px; background: var(--surface); color: #cfe0ff; text-decoration: none; font-size: 12px; }
.iconbtn:hover{ background: #111b34; }
.icon{ font-size: 12px; opacity: .9; }

/* Main map area */
.main{ position: absolute; left: var(--sidebar-w); right: 0; top: 0; bottom: 0; }
#map{ position: absolute; inset: 0; }

/* Mobile sidebar behavior */
@media (max-width: 1024px){
  .sidebar{
    position: fixed;
    transform: translateX(-100%);
    transition: transform .25s ease;
    width: 100vw;
    max-width: 420px;
    background: linear-gradient(180deg, #0b1020 0%, #0d1424 100%);
  }
  .sidebar.open{ transform: translateX(0); } /* ← terug naar normaal */
  .main{ left: 0; }
  body.sidebar-open{ overflow: hidden; }
}

/* Fixed menu-knop (rechtsboven) */
.sidebar-toggle-fixed{
  position: fixed; top: 12px; right: 12px; z-index: 1600;
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px;
  border: 1px solid #2a3b63; border-radius: 8px;
  background: var(--surface); color: #cfe0ff; cursor: pointer;
  box-shadow: 0 6px 18px rgba(0,0,0,.35);
}
.sidebar-toggle-fixed:hover{ background: #111b34; }
/* Op desktop verbergen; daar is de sidebar toch altijd zichtbaar */
@media (min-width: 1025px){
  .sidebar-toggle-fixed{ display: none; }
}

/* Map-specific topbar trigger (mobile) */
#mapTopbar{ position: absolute; left: 12px; top: 12px; z-index: 1300; display: none; }
@media (max-width: 1024px){ #mapTopbar{ display: block !important; } }
#mapTopbar .btn{ background: var(--surface); border: 1px solid #2a3b63; border-radius: 8px; padding: 9px 11px; }
#mapTopbar .btn:hover{ background: #111b34; }

/* History bar */
.history-bar{
  position: absolute; left: 0; right: 0; bottom: 0; padding: 10px 14px;
  background: rgba(12,18,36,.95); border-top: 1px solid #1f2a44; z-index: 1150; display: none; gap: 10px; align-items: center;
}
.history-bar .range{ flex: 1; }
.chip{ padding: 4px 8px; border-radius: 999px; background: #10182a; border: 1px solid #263356; font-size: 11px; color: #c7d2fe; }

/* History panel (in tile) */
.history-panel{ margin-top: 8px; display: none; }
.cal-title{ font-size: .8em; }
.cal-grid{ display: grid; grid-template-columns: repeat(7,minmax(0,1fr)); gap: 6px; border: 1px solid #24304d; border-radius: 8px; padding: 8px; background: var(--surface); }
.cal-cell{ aspect-ratio: 1/1.05; border: 1px solid #2a3b63; border-radius: 8px; padding: 6px; display: flex; flex-direction: column; justify-content: space-between; user-select: none; }
.cal-cell.today{ outline: 1px dashed var(--accent); }
.cal-cell.ok{ cursor: pointer; border-color: #1f4b2e; background: #0d1c12; }
.cal-cell.muted{ color: #7c87a0; }
.cal-cell.disabled{ opacity: .7; }
.cal-badge{ font-size: 10px; color: #9fb4ff; }
.cal-hint{ margin-top: 6px; font-size: 12px; color: var(--muted); }
.sessions-list{ display: none; border: 1px solid #24304d; border-radius: 8px; padding: 6px; background: var(--surface); }
.session-item{ display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px; border: 1px solid #2a3b63; border-radius: 8px; cursor: pointer; margin: 6px 0; }
.session-item:hover{ background: #111b34; }
.session-item .when{ font-weight: 600; }
.session-item .meta{ font-size: 12px; color: #8fa1c7; }

 /* lichte accentuering voor "alleen-locatie" dagen */
.cal-cell.ping { background: rgba(96,165,250,.06); }
.cal-cell.ping .cal-badge {
  border: 1px solid #3b82f6;
  background: rgba(59,130,246,.12);
}

/* Members rows (groups tab in sidebar) */
.member{ display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px; border-radius: 8px; cursor: pointer; }
.member:hover{ background: #111b34; }
.member .left{ display: flex; align-items: center; gap: 8px; }
.member .avatar{ width: 26px; height: 26px; border-radius: 50%; background: #1b2559; border: 1px solid #2a3b63; display: flex; align-items: center; justify-content: center; font-size: 12px; color: #cbd5e1; }

/* Leaflet look/tweaks */
.leaflet-container{ background: #0a0f1f; font-family: inherit; }
.leaflet-top, .leaflet-bottom{ z-index: 800; }
.leaflet-control-attribution{ background: rgba(10,15,31,.6); color: var(--muted); }

/* ============================================================================
   Utilities & Print
   ============================================================================ */
.hidden{ display: none !important; }
.center{ display: flex; align-items: center; justify-content: center; }

@media print{
  .mini-topbar, .alert-container, .modal, .sidebar, .history-bar, .topbar { display: none !important; }
  body{ background: #fff; color: #000; }
  .section, .card{ border: 1px solid #ccc; box-shadow: none; }
}

/* ============================================================================
   AUTH (login/register) – compact, matches app
   ============================================================================ */
.auth-page{
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 600px at 20% -10%, #12204a 0%, transparent 60%),
              radial-gradient(1200px 600px at 120% 110%, #0d1a36 0%, transparent 60%),
              var(--bg);
  padding: 16px;
}
.auth-container{ width: 100%; max-width: 420px; }

.auth-header{ text-align: center; color: #e6efff; margin-bottom: 14px; }
.auth-header .logo{ width: 64px; height: 64px; display: block; margin: 0 auto 10px; filter: drop-shadow(0 6px 18px rgba(0,0,0,.35)); }
.auth-header h1{ margin: 0 0 4px; font-size: 1.4rem; font-weight: 800; letter-spacing: .2px; }
.auth-header p{ margin: 0; color: #9db2df; }

.auth-form-container{ background: var(--surface); border: 1px solid #1f2a44; border-radius: 12px; padding: 16px; box-shadow: 0 24px 64px rgba(0,0,0,.45); margin-bottom: 12px; }
.auth-form{ margin-bottom: 10px; }

/* Form extras */
.password-input{ position: relative; }
.password-toggle{
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  background: none; border: 1px solid #2a3b63; color: #cfe0ff;
  padding: 4px 8px; border-radius: 6px; cursor: pointer; font-size: .8rem;
}
.password-toggle:hover{ background: #111b34; }

.checkbox-group{ margin-top: 6px; }
.checkbox-label{ display: flex; align-items: flex-start; gap: 10px; cursor: pointer; }
.checkbox-label input[type="checkbox"]{ display: none; }
.checkmark{ width: 20px; height: 20px; border: 2px solid #2a3b63; border-radius: 6px; background: #0b1220; position: relative; flex-shrink: 0; }
.checkbox-label input[type="checkbox"]:checked + .checkmark{ background: #102152; border-color: #2b5cd6; }
.checkbox-label input[type="checkbox"]:checked + .checkmark::after{
  content: '✓'; position: absolute; inset: 0; display: grid; place-items: center;
  color: #cfe0ff; font-size: .85rem; font-weight: 700;
}

/* Button mapping: reuse .btn.primary */
.btn-primary{ border-color: #2b5cd6 !important; background: #102152 !important; }
.btn-block{ width: 100%; justify-content: center; }

/* Spinner in button */
@keyframes spin{ to{ transform: rotate(360deg); } }
.spinner{ width: 16px; height: 16px; border: 2px solid #2a3b63; border-top-color: #cfe0ff; border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; margin-right: 6px; }

/* Links & language switcher */
.auth-links{ display: flex; align-items: center; justify-content: center; gap: 10px; color: #9db2df; font-size: .95rem; }
.auth-links .divider{ color: #2a3b63; }
.language-switcher-container{ text-align: center; }
.language-switcher-container .language-switcher{ display: inline-flex; gap: 6px; padding: 4px; background: #0b1220; border: 1px solid #1f2a44; border-radius: 8px; }
.language-switcher-container .language-switcher .lang-option{ padding: 6px 10px; border-radius: 6px; text-transform: uppercase; font-size: .8rem; background: var(--surface); color: #cfe0ff; }
.language-switcher-container .language-switcher .lang-option.active,
.language-switcher-container .language-switcher .lang-option:hover{ background: #102152; }

/* Small screens */
@media (max-width: 420px){
  .auth-container{ max-width: 100%; }
  .auth-form-container{ padding: 14px; }
}


@media (max-width: 1024px){
  .sidebar-handle{ display: flex; left: 0; }        /* altijd aan de linker schermrand */
  /* Niet meer meeschuiven met de sidebar: handle blijft links staan */
  .sidebar.open + .sidebar-handle{
    left: 0;
    border-left: none;
    border-radius: 0 10px 10px 0;
  }
  .sidebar.open + .sidebar-handle .chev{
    transform: none; /* we wisselen icon via JS (› ↔ ×), rotatie niet nodig */
  }
}



/* Kaart in grijstinten bij historie-modus: alleen tiles, overlays blijven kleur */
#map.greyscale .leaflet-tile {
  filter: grayscale(1) saturate(0) brightness(0.9) contrast(1.05);
}
#map.greyscale .leaflet-control-attribution {
  opacity: .8;
}

/* Verberg de km-badge in de kalender */
.cal-grid .cal-badge {
  display: none !important;
}

/* Klikbare dagen (groen) en niet-klikbare (grijs) – jij had deze al ongeveer */
.cal-grid .cal-cell.ok { cursor:pointer; background:#11311f; border-color:#1e5a33; }
.cal-grid .cal-cell.ok:hover { filter:brightness(1.15) saturate(1.1); }
.cal-grid .cal-cell.muted.disabled { cursor:default; background:#0b1224; color:#64748b; border-color:#24304d; }

/* Actieve (aangeklikte) dag feller */
.cal-grid .cal-cell.ok.active {
  background:#1c8a43;
  border-color:#27ad57;
  color:#fff;
  box-shadow:0 0 0 2px rgba(39,173,87,.3) inset;
}

