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

/* ==================== DESIGN TOKENS ==================== */

:root {
    --cc-orange: #EE7103;
    --cc-orange-hover: #D66503;
    --cc-navy: #0E2841;
    --cc-navy-light: #E6EBF0;
    --cc-violet: #5B1A75;
    --cc-green: #4EA72E;
    --cc-green-light: #EBF7E4;
    --cc-gray: #737373;
    --cc-light-gray: #E8E8E8;
    --cc-red: #dc2626;

    --bg-page: #f3f4f6;
    --bg-card: #fff;
    --bg-input: #fff;
    --bg-toggle: #f9fafb;
    --bg-hover: #f8fbff;
    --text-main: #111827;
    --text-label: #374151;
    --text-muted: #737373;
    --border-card: #e5e7eb;
    --border-input: #d1d5db;
    --border-detail: #f3f4f6;

    --bg-success: #dcfce7;
    --text-success: #166534;
    --border-success: #86efac;
    --bg-warning: #fef3c7;
    --text-warning: #92400e;
    --border-warning: #fcd34d;
    --bg-ok-tint: rgba(78, 167, 46, 0.06);
    --bg-deviation-tint: rgba(220, 38, 38, 0.06);
    --bg-photo-btn: #fef2f2;
    --bg-photo-uploading: #f3f4f6;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --touch-min: 44px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-page: #111827;
        --bg-card: #1f2937;
        --bg-input: #374151;
        --bg-toggle: #374151;
        --bg-hover: #263244;
        --text-main: #f9fafb;
        --text-label: #d1d5db;
        --text-muted: #9ca3af;
        --border-card: #374151;
        --border-input: #4b5563;
        --border-detail: #374151;

        --cc-navy: #1e3a5f;
        --cc-navy-light: #1f2937;
        --cc-violet: #7b3a9e;
        --cc-green-light: #1a3a14;
        --cc-light-gray: #4b5563;

        --bg-success: #14532d;
        --text-success: #86efac;
        --border-success: #166534;
        --bg-warning: #451a03;
        --text-warning: #fcd34d;
        --border-warning: #92400e;
        --bg-ok-tint: rgba(78, 167, 46, 0.12);
        --bg-deviation-tint: rgba(220, 38, 38, 0.12);
        --bg-photo-btn: rgba(220, 38, 38, 0.15);
        --bg-photo-uploading: #374151;
    }
}

/* ==================== RESET & BASE ==================== */

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

html {
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    color: var(--text-main);
    background: var(--bg-page);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overscroll-behavior-y: contain;
}

/* ==================== APP SHELL ==================== */

.app-shell {
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
    max-width: 600px;
    margin: 0 auto;
}

.app-header {
    background: var(--cc-navy);
    padding: calc(var(--safe-top) + 8px) 16px 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 10;
}

.header-logo { height: 28px; }

.header-title {
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.app-content {
    flex: 1;
    padding: 16px;
    padding-bottom: calc(72px + var(--safe-bottom));
}

/* ==================== TAB BAR ==================== */

.app-tabbar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-width: 600px;
    margin: 0 auto;
    background: var(--cc-violet);
    display: flex;
    justify-content: space-around;
    padding: 6px 0 calc(6px + var(--safe-bottom));
    z-index: 10;
}

.tab-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: rgba(255, 255, 255, 0.5);
    font-size: 11px;
    font-weight: 600;
    padding: 6px 16px;
    border-radius: var(--radius-sm);
    transition: color 0.2s;
    min-width: var(--touch-min);
    min-height: var(--touch-min);
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
}

.tab-item:hover, .tab-item.active { color: #fff; }

.tab-item.active {
    position: relative;
}

.tab-item.active::after {
    content: '';
    position: absolute;
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 3px;
    border-radius: 2px;
    background: var(--cc-orange);
}

.tab-icon {
    width: 22px;
    height: 22px;
    margin-bottom: 2px;
    flex-shrink: 0;
}

.tab-label { font-size: 10px; }

/* ==================== TYPOGRAPHY ==================== */

.page-title {
    font-size: 1.375rem;
    font-weight: 700;
    color: var(--cc-orange);
    margin: 0 0 16px 0;
}

/* ==================== CARDS ==================== */

.card {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-lg);
    padding: 14px 16px;
    margin-bottom: 10px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
    transition: transform 0.1s ease;
}

.card:active {
    transform: scale(0.985);
}

/* ==================== FORMS ==================== */

.form-group { margin-bottom: 16px; }

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: var(--text-label);
    font-size: 13px;
}

.form-control {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border-input);
    border-radius: var(--radius-md);
    font-size: 16px;
    font-family: inherit;
    background: var(--bg-input);
    color: var(--text-main);
    min-height: var(--touch-min);
    transition: border-color 0.15s, box-shadow 0.15s;
    -webkit-appearance: none;
    appearance: none;
}

.form-control:focus {
    outline: none;
    border-color: var(--cc-orange);
    box-shadow: 0 0 0 3px rgba(238, 113, 3, 0.15);
}

select.form-control {
    appearance: auto;
    -webkit-appearance: auto;
    background-image: none;
}

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

/* ==================== BUTTONS ==================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: var(--touch-min);
    padding: 0 18px;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 15px;
    font-family: inherit;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background 0.15s, transform 0.1s;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

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

.btn-primary { background: var(--cc-orange); color: #fff; width: 100%; }
.btn-primary:hover { background: var(--cc-orange-hover); }

.btn-secondary { background: var(--bg-card); color: var(--text-main); border-color: var(--border-input); }
.btn-secondary:hover { background: var(--bg-hover); }

.btn-sm { min-height: 36px; padding: 0 12px; font-size: 13px; }

/* ==================== FILTER BAR ==================== */

.filter-bar { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.filter-bar select { flex: 1; min-width: 120px; }

/* ==================== QUESTION CARDS + KLEURCODERING ==================== */

.question-card {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-lg);
    padding: 14px 16px;
    margin-bottom: 10px;
    transition: background 0.2s, border-color 0.2s;
}

.question-card.answered-ok {
    background: var(--bg-ok-tint);
    border-color: var(--cc-green);
}

.question-card.answered-deviation {
    background: var(--bg-deviation-tint);
    border-color: var(--cc-red);
}

.question-card.answered-warning {
    background: #fffbeb;
    border-color: #f59e0b;
}

.question-text {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 10px;
    color: var(--text-main);
    line-height: 1.4;
}

/* ==================== TOGGLE BUTTONS ==================== */

.btn-group { display: flex; gap: 6px; }

.btn-toggle {
    flex: 1;
    min-height: var(--touch-min);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-input);
    background: var(--bg-toggle);
    color: var(--text-label);
    font-weight: 600;
    font-size: 15px;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
    -webkit-tap-highlight-color: transparent;
}

.btn-toggle:active { transform: scale(0.95); }

.btn-toggle.active {
    background: var(--cc-orange);
    color: #fff;
    border-color: var(--cc-orange);
}

/* ==================== NUMERIC INPUT ==================== */

.numeric-row { display: flex; align-items: center; gap: 8px; }
.numeric-row input { width: 120px; }
.numeric-unit { font-size: 14px; color: var(--text-label); }
.numeric-range { font-size: 12px; color: var(--text-muted); }

/* ==================== VOORTGANGSBALK ==================== */

.progress-container { margin-bottom: 16px; }

.progress-label {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.progress-bar-track {
    height: 6px;
    background: var(--border-card);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s ease, background-color 0.3s ease;
}

/* ==================== HISTORIE ==================== */

.result-card {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-lg);
    padding: 14px 16px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    min-height: 56px;
    transition: background 0.15s, transform 0.1s;
    -webkit-tap-highlight-color: transparent;
}

.result-card:active { transform: scale(0.985); }
.result-card:hover { background: var(--bg-hover); }

.deviation-indicator {
    width: 4px;
    border-radius: 2px;
    align-self: stretch;
    flex-shrink: 0;
    min-height: 36px;
}

.deviation-none { background: var(--cc-green); }
.deviation-yes { background: var(--cc-red); }

.result-info { flex: 1; min-width: 0; }
.result-name { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.result-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.result-deviation { font-size: 12px; font-weight: 600; margin-top: 1px; }

.text-green { color: var(--cc-green); }
.text-red { color: var(--cc-red); }
.text-gray { color: var(--text-muted); }

.result-arrow { color: var(--border-input); font-size: 20px; flex-shrink: 0; }

/* ==================== ALERTS ==================== */

.alert {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    margin-bottom: 16px;
    font-size: 14px;
    line-height: 1.4;
}

.alert-success { background: var(--bg-success); color: var(--text-success); border: 1px solid var(--border-success); }
.alert-warning { background: var(--bg-warning); color: var(--text-warning); border: 1px solid var(--border-warning); }

.empty-state { text-align: center; color: var(--text-muted); padding: 48px 24px; font-size: 14px; }

.loading { text-align: center; padding: 40px; color: var(--text-muted); }

/* ==================== FOTO'S ==================== */

.photo-section { margin-top: 10px; }

.photo-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    border: 1px dashed var(--cc-red);
    background: var(--bg-photo-btn);
    color: var(--cc-red);
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    min-height: 36px;
    transition: opacity 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.photo-btn:active { opacity: 0.7; }

.photo-thumbs { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }

.photo-thumb {
    position: relative;
    width: 72px;
    height: 72px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border-card);
}

.photo-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.photo-thumb-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(220, 38, 38, 0.9);
    color: #fff;
    border: none;
    font-size: 13px;
    line-height: 22px;
    text-align: center;
    cursor: pointer;
    padding: 0;
}

.photo-uploading {
    width: 72px;
    height: 72px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-card);
    background: var(--bg-photo-uploading);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    color: var(--text-muted);
}

/* ==================== DASHBOARD ==================== */

.dashboard-summary {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.summary-stat {
    flex: 1;
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-lg);
    padding: 14px 10px;
    text-align: center;
}

.summary-value {
    font-size: 28px;
    font-weight: 700;
    line-height: 1.1;
}

.summary-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.section-title {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin: 20px 0 10px;
    padding-left: 2px;
    color: var(--text-muted);
}

.section-title.section-overdue { color: var(--cc-red); }
.section-title.section-due { color: var(--cc-orange); }
.section-title.section-done { color: var(--cc-green); }

.schedule-card {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-lg);
    padding: 12px 14px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: transform 0.1s;
}

.schedule-card:active { transform: scale(0.985); }

.schedule-indicator {
    width: 4px;
    border-radius: 2px;
    align-self: stretch;
    flex-shrink: 0;
    min-height: 36px;
}

.schedule-indicator.overdue { background: var(--cc-red); }
.schedule-indicator.due { background: var(--cc-orange); }
.schedule-indicator.done { background: var(--cc-green); }
.schedule-indicator.neutral { background: var(--cc-light-gray); }

.schedule-info { flex: 1; min-width: 0; }

.schedule-name {
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.schedule-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.schedule-detail {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

.schedule-due {
    font-size: 12px;
    font-weight: 700;
    color: var(--cc-orange);
    flex-shrink: 0;
    white-space: nowrap;
}

.schedule-card.overdue .schedule-due { color: var(--cc-red); }

.schedule-check {
    font-size: 18px;
    color: var(--cc-green);
    font-weight: 700;
    flex-shrink: 0;
}

/* ==================== QR SCANNER ==================== */

.qr-scan-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    min-height: var(--touch-min);
    padding: 10px 16px;
    margin-bottom: 16px;
    border-radius: var(--radius-md);
    border: 2px dashed var(--cc-orange);
    background: transparent;
    color: var(--cc-orange);
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
    -webkit-tap-highlight-color: transparent;
}

.qr-scan-btn:active { transform: scale(0.97); }
.qr-scan-btn:hover { background: rgba(238, 113, 3, 0.06); }

.qr-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.qr-modal {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 400px;
    overflow: hidden;
}

.qr-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    font-weight: 600;
    font-size: 15px;
    color: var(--text-main);
    border-bottom: 1px solid var(--border-card);
}

.qr-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: var(--bg-toggle);
    color: var(--text-main);
    font-size: 20px;
    line-height: 32px;
    text-align: center;
    cursor: pointer;
    padding: 0;
}

#qr-reader {
    width: 100%;
}

#qr-reader video {
    border-radius: 0 !important;
}

/* ==================== QR DISPLAY ==================== */

.qr-display {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--border-card);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.qr-canvas {
    display: flex;
    justify-content: center;
}

.qr-canvas canvas {
    border-radius: var(--radius-sm);
}

/* ==================== FREQUENTIE BADGES ==================== */

.freq-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-right: 6px;
    vertical-align: middle;
}

.freq-daily {
    background: rgba(220, 38, 38, 0.12);
    color: var(--cc-red);
}

.freq-weekly {
    background: rgba(238, 113, 3, 0.12);
    color: var(--cc-orange);
}

.freq-monthly {
    background: rgba(59, 130, 246, 0.12);
    color: #3b82f6;
}

@media (prefers-color-scheme: dark) {
    .freq-daily {
        background: rgba(220, 38, 38, 0.25);
    }
    .freq-weekly {
        background: rgba(238, 113, 3, 0.25);
    }
    .freq-monthly {
        background: rgba(59, 130, 246, 0.25);
    }
}

/* ==================== SYSTEM ==================== */

.loading-progress circle:last-child { stroke: var(--cc-orange); }

#blazor-error-ui {
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}
