/*
 * Werk-tijd.nl: één stylesheet voor alle pagina's.
 * --accent komt uit het gekozen kleurthema (profiel); data-modus op <html> = auto | licht | donker.
 */

:root {
    --accent: #2563eb;
    --accent-text: #fff;
    --bg: #f4f5f7;
    --surface: #ffffff;
    --surface-2: #f9fafb;
    --text: #111827;
    --muted: #6b7280;
    --border: #e5e7eb;
    --ok: #15803d;
    --ok-bg: #dcfce7;
    --bad: #b91c1c;
    --bad-bg: #fee2e2;
    --warn-bg: #fef3c7;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
    --shadow-lg: 0 10px 30px rgba(16, 24, 40, 0.12);
    --sidebar: 256px;
    --accent-soft: color-mix(in srgb, var(--accent) 12%, var(--surface));
    --accent-hover: color-mix(in srgb, var(--accent) 85%, black);
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root[data-modus="auto"] {
        --bg: #0e1116; --surface: #161a21; --surface-2: #1c212a; --text: #e6e8eb; --muted: #9aa3ae;
        --border: #2a303b; --ok-bg: #12321f; --ok: #4ade80; --bad-bg: #3b1515; --bad: #f87171; --warn-bg: #3a2e0f;
        --shadow: 0 1px 2px rgba(0, 0, 0, 0.4); --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.5);
        --accent-hover: color-mix(in srgb, var(--accent) 80%, white);
        color-scheme: dark;
    }
}

:root[data-modus="donker"] {
    --bg: #0e1116; --surface: #161a21; --surface-2: #1c212a; --text: #e6e8eb; --muted: #9aa3ae;
    --border: #2a303b; --ok-bg: #12321f; --ok: #4ade80; --bad-bg: #3b1515; --bad: #f87171; --warn-bg: #3a2e0f;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4); --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.5);
    --accent-hover: color-mix(in srgb, var(--accent) 80%, white);
    color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
}

h1, h2, h3 { line-height: 1.25; margin: 0 0 0.5rem; letter-spacing: -0.01em; }
h1 { font-size: 1.6rem; font-weight: 700; }
h2 { font-size: 1.15rem; font-weight: 650; }
h3 { font-size: 1rem; font-weight: 650; }
p { margin: 0 0 0.75rem; }
a { color: var(--accent); }
code { background: var(--accent-soft); padding: 0 4px; border-radius: 4px; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Opbouw: zijmenu + inhoud ---------- */

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 30;
    width: var(--sidebar);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 1rem 0.75rem;
    background: var(--surface);
    border-right: 1px solid var(--border);
    overflow-y: auto;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.25rem 0.5rem 1rem;
    color: var(--text);
    font-weight: 700;
    text-decoration: none;
    border-bottom: 1px solid var(--border);
}

.sidebar-brand img { width: 40px; height: 40px; object-fit: contain; border-radius: 8px; }
.sidebar nav { flex: 1; }

.nav-group {
    margin: 1rem 0.75rem 0.35rem;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.55rem 0.75rem;
    border-radius: var(--radius-sm);
    color: var(--text);
    font-weight: 500;
    text-decoration: none;
}

.nav-link:hover { background: var(--surface-2); }
.nav-link.active { background: var(--accent-soft); color: var(--accent); font-weight: 650; }
.nav-link .icon { color: var(--muted); }
.nav-link.active .icon { color: var(--accent); }

.sidebar-foot { border-top: 1px solid var(--border); padding-top: 0.5rem; }
.sidebar-user { display: flex; align-items: center; gap: 0.7rem; padding: 0.55rem 0.75rem; color: var(--muted); font-size: 0.9rem; }
.sidebar-user span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.content { padding: 2rem clamp(1rem, 3vw, 2.5rem) 4rem; max-width: 1280px; }
.with-nav .content { margin-left: var(--sidebar); }
.no-nav .content { max-width: none; }

.mobilebar { display: none; }
.sidebar-backdrop { display: none; }

@media (max-width: 900px) {
    .sidebar { transform: translateX(-105%); transition: transform 0.2s ease; box-shadow: var(--shadow-lg); }
    .nav-open .sidebar { transform: none; }
    .nav-open .sidebar-backdrop { display: block; position: fixed; inset: 0; z-index: 25; background: rgba(0, 0, 0, 0.35); }
    .with-nav .content { margin-left: 0; padding-top: 1rem; }
    .mobilebar {
        position: sticky; top: 0; z-index: 20;
        display: flex; align-items: center; gap: 0.6rem;
        padding: 0.5rem 0.75rem;
        background: var(--surface); border-bottom: 1px solid var(--border);
    }
    .mobilebar-logo { width: 28px; height: 28px; object-fit: contain; }
    .mobilebar-title { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* ---------- Paginakop ---------- */

.page-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; }
.page-header p { margin: 0.25rem 0 0; }
.page-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }

/* ---------- Knoppen ---------- */

.btn, button, input[type="submit"] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    min-height: 40px;
    padding: 0.5rem 1rem;
    border: 1px solid var(--accent);
    border-radius: var(--radius-sm);
    background: var(--accent);
    color: var(--accent-text);
    font: inherit;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.btn:hover, button:hover, input[type="submit"]:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn:focus-visible, button:focus-visible { outline: 3px solid var(--accent-soft); outline-offset: 2px; }

.btn.secondary, .back-button { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn.secondary:hover, .back-button:hover { background: var(--surface-2); border-color: var(--muted); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.danger { background: var(--surface); color: var(--bad); border-color: var(--border); }
.btn.danger:hover { background: var(--bad-bg); border-color: var(--bad); }
.btn.small, .save-btn { min-height: 32px; padding: 0.3rem 0.7rem; font-size: 0.85rem; }
.btn.block { width: 100%; }

.icon-btn, .btn-icon {
    display: inline-flex; align-items: center; justify-content: center;
    min-height: 36px; width: 36px; padding: 0;
    background: transparent; color: var(--muted); border: 1px solid transparent; border-radius: var(--radius-sm);
}

.icon-btn:hover, .btn-icon:hover { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn-icon:hover { color: var(--bad); }

button:disabled, input[type="submit"]:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }

.toolbar, .actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 1rem 0; }

/* ---------- Formulieren ---------- */

label { display: block; margin: 0 0 0.35rem; font-weight: 600; font-size: 0.88rem; }
label > input, label > select, label > textarea { margin-top: 0.35rem; font-weight: 400; }

.field { margin-bottom: 1rem; }
.field .hint { margin-top: 0.3rem; font-size: 0.82rem; color: var(--muted); }

input[type="text"], input[type="password"], input[type="number"], input[type="date"], input[type="time"],
input[type="email"], input[type="search"], input[type="file"], select, textarea {
    display: block;
    width: 100%;
    min-height: 42px;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font: inherit;
}

textarea { min-height: 80px; resize: vertical; }

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

input:disabled, select:disabled { background: var(--surface-2); color: var(--muted); }
input[type="checkbox"], input[type="radio"] { width: 1.1rem; height: 1.1rem; accent-color: var(--accent); vertical-align: middle; margin: 0; }

label.check, .checkbox-wrapper, .checkbox-label { display: flex; align-items: center; gap: 0.55rem; font-weight: 500; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0 1rem; }
.form-grid .span-all { grid-column: 1 / -1; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 1rem; }

.filters {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.75rem 1rem;
    align-items: end;
    padding: 1rem;
    margin-bottom: 1.25rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.filters label { margin: 0; }
.filters:not(:has(label)) { display: none; }

/* Gesegmenteerde keuze (bijv. Uren | Kilometers) */
.segmented { display: inline-flex; padding: 3px; gap: 3px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; }
.segmented button, .segmented a {
    min-height: 34px; padding: 0.3rem 0.9rem; border: 0; border-radius: 8px;
    background: transparent; color: var(--muted); font-weight: 600; text-decoration: none;
    display: inline-flex; align-items: center; gap: 0.4rem;
}
.segmented button:hover, .segmented a:hover { background: transparent; color: var(--text); }
.segmented .active, .segmented [aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* Kleurkeuze */
.swatches { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.swatch { position: relative; }
.swatch input { position: absolute; opacity: 0; }
.swatch span {
    display: block; width: 40px; height: 40px; border-radius: 50%;
    background: var(--c); border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--border); cursor: pointer;
}
.swatch input:checked + span { box-shadow: 0 0 0 2px var(--c); }
.swatch input:focus-visible + span { outline: 3px solid var(--accent-soft); }

.choice-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0.5rem; }
.choice { display: flex; align-items: center; gap: 0.6rem; padding: 0.7rem 0.9rem; border: 1px solid var(--border); border-radius: var(--radius-sm); font-weight: 500; cursor: pointer; }
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }

/* ---------- Kaarten, meldingen, cijfers ---------- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
}

.card.narrow { max-width: 520px; }
.card-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem; margin-bottom: 1rem; }
.card-header h2 { margin: 0; }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 1.25rem; align-items: start; }
@media (max-width: 1100px) { .grid-2 { grid-template-columns: 1fr; } }

.notice-ok, .notice-error, .notice-warn { padding: 0.75rem 1rem; border-radius: var(--radius-sm); font-weight: 500; margin: 0 0 1rem; }
.notice-ok { background: var(--ok-bg); color: var(--ok); }
.notice-error { background: var(--bad-bg); color: var(--bad); }
.notice-warn { background: var(--warn-bg); }
.error-message { color: var(--bad); font-weight: 600; }

.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 0.75rem; margin: 0 0 1.25rem; }
.stat { padding: 1rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.stat span { display: block; font-size: 0.82rem; color: var(--muted); }
.stat strong { font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.stat.plus strong { color: var(--ok); }
.stat.min strong { color: var(--bad); }

.plus { background: var(--ok-bg); }
.min { background: var(--bad-bg); }

.badge { display: inline-block; padding: 0.1rem 0.5rem; border-radius: 99px; font-size: 0.75rem; font-weight: 600; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.badge.ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.badge.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

.progress { height: 10px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--accent); border-radius: 99px; transition: width 0.8s ease; }

.empty { padding: 2rem 1rem; text-align: center; color: var(--muted); }

/* Lijst met registraties (startpagina) */
.entries { list-style: none; margin: 0; padding: 0; }
.entry { display: grid; grid-template-columns: 92px minmax(0, 1fr) auto auto; gap: 0.75rem; align-items: center; padding: 0.7rem 0; border-bottom: 1px solid var(--border); }
.entry:last-child { border-bottom: 0; }
.entry-time { font-weight: 650; font-variant-numeric: tabular-nums; }
.entry-main { min-width: 0; }
.entry-main strong, .entry-main span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry-main span { color: var(--muted); font-size: 0.85rem; }
.entry-dur { font-variant-numeric: tabular-nums; color: var(--muted); }

/* ---------- Tabellen ---------- */

.table-scroll { width: 100%; overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 1.25rem; }
.table-scroll > .data-table { border: 0; }

table { border-collapse: collapse; }

.data-table { width: 100%; font-size: 0.88rem; background: var(--surface); }
.data-table th, .data-table td { padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.data-table thead th { position: sticky; top: 0; background: var(--surface-2); color: var(--muted); font-size: 0.75rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; white-space: nowrap; }
.data-table tbody tr:hover { background: var(--surface-2); }
.data-table tfoot td, .data-table tr.total td { font-weight: 700; background: var(--surface-2); }
.data-table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.data-table .right { text-align: right; }
.data-table .empty { text-align: center; color: var(--muted); padding: 2rem; }
.data-table.compact th, .data-table.compact td { padding: 0.4rem 0.5rem; }
.data-table input, .data-table select { min-height: 34px; padding: 0.3rem 0.5rem; }
.data-table td[contenteditable="true"] { background: color-mix(in srgb, var(--warn-bg) 50%, var(--surface)); cursor: text; }
.data-table td[contenteditable="true"]:focus { outline: 2px solid var(--accent); }

.columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; }

.row-saturday { background: color-mix(in srgb, #fb923c 18%, var(--surface)); }
.row-sunday { background: color-mix(in srgb, #ef4444 16%, var(--surface)); }
.row-kms { background: color-mix(in srgb, #3b82f6 14%, var(--surface)); }
.row-locked td[contenteditable] { background: var(--surface-2) !important; }

.save-btn.changed { background: #f59e0b; border-color: #f59e0b; color: #111; }
.save-btn.saved { background: var(--ok); border-color: var(--ok); }

.registraties-table { width: 100%; font-size: 0.9rem; }
.registraties-table th, .registraties-table td { padding: 0.35rem 0.5rem; border-bottom: 1px solid var(--border); text-align: left; }

/* ---------- Tabbladen ---------- */

.tabs { display: flex; flex-wrap: wrap; gap: 0.25rem; margin-bottom: 1.5rem; border-bottom: 1px solid var(--border); }
.tabs a { padding: 0.6rem 1rem; margin-bottom: -1px; border-bottom: 2px solid transparent; color: var(--muted); font-weight: 600; text-decoration: none; }
.tabs a:hover { color: var(--text); }
.tabs a.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ---------- Startscherm: bedrijfskeuze en inloggen ---------- */

.auth { min-height: 100vh; display: grid; place-items: center; padding: 2rem 1rem; }
.auth-card { width: 100%; max-width: 420px; padding: 2rem; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg); }
.auth-card.wide { max-width: 720px; }
.auth-logo { display: block; width: 88px; height: 88px; object-fit: contain; margin: 0 auto 1rem; }
.auth-logo.wide { width: 150px; height: 164px; }
.auth-card h1 { text-align: center; }
.auth-card .muted { text-align: center; }
.auth-card .btn.block { margin-top: 0.5rem; }
.auth-switch { display: flex; align-items: center; justify-content: center; gap: 0.4rem; margin-top: 1.25rem; font-size: 0.9rem; }

.company-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0.75rem; margin-top: 1.5rem; }
.company {
    display: flex; flex-direction: column; align-items: center; gap: 0.6rem;
    padding: 1.1rem 0.75rem; border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--surface); color: var(--text); font-weight: 600; text-align: center; text-decoration: none;
    transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}
.company:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow); }
.company img { width: 64px; height: 64px; object-fit: contain; }

/* ---------- Diversen ---------- */

fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; margin: 0 0 1rem; }
legend { padding: 0 0.4rem; font-weight: 650; }
.settings section { margin-bottom: 2rem; }

.tooltip-container { position: relative; display: inline-block; cursor: help; margin-left: 0.5rem; }
.tooltip-icon { width: 22px; height: 22px; display: flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--accent); color: #fff; font-weight: 700; font-size: 13px; }
.tooltip-text { visibility: hidden; opacity: 0; position: absolute; bottom: 30px; left: 50%; transform: translateX(-50%); padding: 8px 10px; border-radius: 6px; background: #111; color: #fff; font-size: 12px; white-space: nowrap; transition: opacity 0.2s; z-index: 5; }
.tooltip-container:hover .tooltip-text { visibility: visible; opacity: 1; }

.switch { position: relative; display: inline-block; width: 40px; height: 22px; margin: 0; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.slider { position: absolute; inset: 0; background: var(--border); border-radius: 22px; cursor: pointer; transition: 0.2s; }
.slider::before { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: 0.2s; box-shadow: var(--shadow); }
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(18px); }
.switch input:focus-visible + .slider { outline: 3px solid var(--accent-soft); }

.old-value { color: var(--muted); text-decoration: line-through; display: block; }
.new-value { color: var(--accent); display: block; }

/* Klanten-beheer */
.split { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 1.25rem; align-items: start; }
@media (max-width: 900px) { .split { grid-template-columns: 1fr; } }
.list { list-style: none; margin: 0; padding: 0; max-height: 70vh; overflow-y: auto; }
.list a { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; padding: 0.55rem 0.75rem; border-radius: var(--radius-sm); color: var(--text); text-decoration: none; }
.list a:hover { background: var(--surface-2); }
.list a.active { background: var(--accent-soft); color: var(--accent); font-weight: 650; }
.list .hidden-item { color: var(--muted); text-decoration: line-through; }
details.translations summary { cursor: pointer; color: var(--muted); font-size: 0.85rem; }
details.translations[open] summary { margin-bottom: 0.5rem; }

/* Melding rechtsonder */
.toast {
    position: fixed; right: 1rem; bottom: 1rem; z-index: 50;
    max-width: min(420px, calc(100vw - 2rem));
    padding: 0.8rem 1rem; border-radius: var(--radius-sm);
    background: #111827; color: #fff; box-shadow: var(--shadow-lg);
    opacity: 0; transform: translateY(10px); pointer-events: none; transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: none; }
.toast.error { background: #991b1b; }

/* KlokPC */
.kiosk { min-height: 100vh; display: grid; place-items: center; text-align: center; padding: 2rem; }
.kiosk h1 { font-size: clamp(2rem, 5vw, 3.5rem); }
.kiosk .clock { font-size: clamp(2.5rem, 8vw, 6rem); font-weight: 700; font-variant-numeric: tabular-nums; }
.kiosk img.state { width: 240px; max-width: 60vw; border-radius: 30%; box-shadow: var(--shadow-lg); }
.kiosk .result { font-size: clamp(1.25rem, 3vw, 2rem); }

/* ---------- Print ---------- */

@media print {
    .sidebar, .mobilebar, .tabs, .filters, .toolbar, .page-actions, button, .btn { display: none !important; }
    body { background: #fff; color: #000; }
    .with-nav .content { margin: 0; padding: 0; max-width: none; }
    .table-scroll, .card { box-shadow: none; border: 0; overflow: visible; }
}
