:root {
    /* ==================== COLOR TOKENS ==================== */

    /* Brand Palette - Rederij Cascade */
    --brand-primary: #003366;
    /* Marineblauw */
    --brand-accent: #00AEEF;
    /* Helderblauw */

    /* Status Palette - Operationeel (Dominant) */
    --status-ok: #059669;
    /* Emerald-600 */
    --status-warn: #d97706;
    /* Amber-600 */
    --status-deny: #dc2626;
    /* Red-600 */
    --status-info: #00AEEF;
    /* Helderblauw */

    /* Status Backgrounds (Simulated typically 10-15% opacity) */
    --status-ok-bg: #ecfdf5;
    /* Emerald-50 */
    --status-warn-bg: #fffbeb;
    /* Amber-50 */
    --status-deny-bg: #fef2f2;
    /* Red-50 */
    --status-info-bg: #e6f7ff;
    /* Light Accent */

    /* Neutral Palette (Light Mode Default) */
    --bg-primary: #ffffff;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e6e6e6;
    /* Neutral-100 */

    --text-primary: #003366;
    /* Neutral-900 / Marineblauw voor tekst */
    --text-secondary: #5a738e;
    /* Blauw/Grijs */
    --text-muted: #a3a3a3;
    /* Neutral-400 */
    --text-inverse: #ffffff;

    --border-subtle: #e6e6e6;
    /* Neutral-200 */
    --border-focus: #00AEEF;
    /* Blue-300 */

    /* Shadows */
    --shadow-card: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    /* shadow-sm */
    --shadow-float: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    /* shadow-md */

    /* Dimensions */
    --radius-card: 16px;
    /* rounded-2xl */
    --radius-button: 12px;
    /* rounded-xl */
    --radius-pill: 999px;
    --radius-input: 12px;

    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;

    /* Typography */
    --font-family: 'Inter', system-ui, -apple-system, sans-serif;
}


/* ==================== RESET & BASE ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

/* ==================== UTILITIES ==================== */
.hidden {
    display: none !important;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

#app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding-bottom: 90px;
}

/* ==================== BRANDING & LOGOS ==================== */
.brand-logo {
    display: block;
    margin: 0 auto;
    object-fit: contain;
}

.login-logo {
    width: 280px;
    height: auto;
    margin-bottom: var(--spacing-lg);
}

.header-logo {
    height: auto;
    max-height: 38px;
    width: 150px;
    margin-right: 12px;
}

h1,
h2,
h3 {
    color: var(--text-primary);
    font-weight: 700;
    letter-spacing: -0.02em;
}

button {
    font-family: inherit;
    border: none;
    outline: none;
    cursor: pointer;
}

input {
    font-family: inherit;
}

/* ==================== LAYOUT COMPONENTS ==================== */

.screen {
    display: none;
    padding: var(--spacing-lg);
    max-width: 600px;
    margin: 0 auto;
    animation: fadeIn 0.2s ease-out;
}

.screen.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.screen-header {
    margin-bottom: var(--spacing-lg);
    text-align: left;
}

.screen-header h1 {
    font-size: 24px;
    color: var(--text-primary);
}

.subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
}

/* ==================== NAVIGATION ==================== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-subtle);
    display: flex;
    overflow-x: auto;
    /* Enable horizontal scroll on mobile */
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* IE and Edge */
    -webkit-overflow-scrolling: touch;
    padding: 12px var(--spacing-md) max(12px, env(safe-area-inset-bottom));
    z-index: 100;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.03);
}

.bottom-nav::-webkit-scrollbar {
    display: none;
}

.nav-item {
    background: transparent;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: var(--text-muted);
    min-width: 72px;
    flex-shrink: 0;
    /* Prevent squishing on mobile */
    transition: color 0.2s;
}

.nav-item.active {
    color: var(--brand-primary);
}

.nav-icon {
    width: 24px;
    height: 24px;
}

.sidebar-logo {
    display: none;
}

.qr-nav-icon {
    object-fit: contain;
}

.nav-item.active .qr-nav-icon {
    filter: brightness(0) saturate(100%) invert(42%) sepia(93%) saturate(401%) hue-rotate(142deg) brightness(97%) contrast(88%);
}

.nav-item span {
    font-size: 11px;
    font-weight: 600;
}

/* ==================== BUTTONS ==================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 20px;
    /* Touch target */
    border-radius: var(--radius-button);
    font-weight: 600;
    font-size: 16px;
    transition: transform 0.1s, opacity 0.2s;
    width: 100%;
}

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

.btn-primary {
    background-color: var(--brand-primary);
    color: var(--text-inverse);
    box-shadow: 0 2px 4px rgba(11, 42, 58, 0.2);
}

.btn-secondary {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
}

.btn-success {
    background-color: var(--status-ok);
    color: white;
}

.btn-warning {
    background-color: var(--status-warn);
    color: black;
}

.btn-error {
    background-color: var(--status-deny);
    color: white;
}

/* ==================== INPUTS ==================== */
.input-field {
    width: 100%;
    padding: 14px;
    border-radius: var(--radius-input);
    border: 1px solid var(--border-subtle);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 16px;
    margin-bottom: var(--spacing-md);
    transition: border-color 0.2s;
}

.input-field:focus {
    border-color: var(--brand-accent);
    outline: none;
    box-shadow: 0 0 0 3px rgba(15, 163, 161, 0.1);
}

/* ==================== CARDS ==================== */
.reservation-card,
.history-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-card);
    padding: var(--spacing-md);
    box-shadow: var(--shadow-card);
    border: 1px solid var(--border-subtle);
    margin-bottom: var(--spacing-md);
    position: relative;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s, background-color 0.2s;
}

.reservation-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-float);
    background-color: var(--bg-primary);
}

.reservation-card:active {
    transform: translateY(0);
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

/* ==================== SCANNER ==================== */
.scanner-container {
    border-radius: var(--radius-card);
    overflow: hidden;
    position: relative;
    background: black;
    margin-bottom: var(--spacing-lg);
    box-shadow: var(--shadow-float);
}

#qr-reader {
    width: 100%;
    /* Force clean edges */
    transform: translateZ(0);
}

.scanner-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.scan-frame {
    width: 260px;
    height: 260px;
    border: 2px solid white;
    border-radius: 20px;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
    position: relative;
}

.scan-frame::after {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    border: 2px solid var(--brand-accent);
    border-radius: 20px;
    opacity: 0.5;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 0.8;
    }

    50% {
        transform: scale(1.02);
        opacity: 0.4;
    }

    100% {
        transform: scale(1);
        opacity: 0.8;
    }
}

.scan-hint {
    text-align: center;
    margin-top: var(--spacing-sm);
    color: white;
    font-size: 14px;
    position: absolute;
    bottom: 20px;
    left: 0;
    right: 0;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* ==================== RESULT MODAL ==================== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 999;
    align-items: flex-end;
    /* Sheet style on mobile */
    justify-content: center;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-secondary);
    width: 100%;
    max-width: 500px;
    border-radius: 24px 24px 0 0;
    /* Top rounded for sheet */
    padding: var(--spacing-lg);
    padding-bottom: max(var(--spacing-lg), env(safe-area-inset-bottom));
    box-shadow: var(--shadow-float);
    animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    max-height: 90vh;
    overflow-y: auto;
}

@media (min-width: 600px) {
    .modal {
        align-items: center;
    }

    .modal-content {
        border-radius: 24px;
        padding-bottom: var(--spacing-lg);
    }
}

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

    to {
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-md);
}

.modal-header h2 {
    font-size: 20px;
    color: var(--brand-primary);
}

@media (prefers-color-scheme: dark) {
    .modal-header h2 {
        color: var(--text-primary);
    }
}

.modal-close {
    background: var(--bg-tertiary);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: var(--text-secondary);
}

/* ==================== STATUS UTILS ==================== */

.result-info {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding-bottom: var(--spacing-sm);
    border-bottom: 1px solid var(--border-subtle);
}

.info-label {
    font-size: 14px;
    color: var(--text-secondary);
}

.info-value {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

/* Status Colors & Badges */
.text-success {
    color: var(--status-ok) !important;
}

.text-warning {
    color: var(--status-warn) !important;
}

.text-error {
    color: var(--status-deny) !important;
}

.text-primary {
    color: var(--brand-accent) !important;
}

/* Warning Box */
.warning-box {
    background: var(--status-warn-bg);
    border: 1px solid var(--status-warn);
    color: #92400E;
    /* Darker amber for readability */
    padding: 12px;
    border-radius: var(--radius-button);
    font-weight: 500;
    font-size: 14px;
    margin: var(--spacing-sm) 0;
}

/* Persons Input */
.persons-input-group {
    margin-top: var(--spacing-md);
    padding: var(--spacing-md);
    background: var(--bg-primary);
    /* Slightly distinct background */
    border-radius: var(--radius-card);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.persons-input-group label {
    font-weight: 600;
    font-size: 14px;
}

.persons-input-group input {
    width: 60px;
    text-align: center;
    font-size: 18px;
    font-weight: 700;
    padding: 8px;
    border-radius: 8px;
}

/* ==================== RESERVATION LIST ==================== */
.ship-toggle {
    display: flex;
    background: var(--bg-tertiary);
    padding: 4px;
    border-radius: var(--radius-button);
    margin-bottom: var(--spacing-md);
}

.toggle-btn {
    flex: 1;
    padding: 8px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
}

.toggle-btn.active {
    background: var(--bg-secondary);
    color: var(--brand-primary);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

@media (prefers-color-scheme: dark) {
    .toggle-btn.active {
        color: var(--text-primary);
    }
}

.reservation-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.reservation-name {
    font-weight: 700;
    font-size: 16px;
    margin-bottom: 2px;
}

.reservation-time {
    font-size: 13px;
    color: var(--text-secondary);
}

.reservation-meta {
    display: flex;
    gap: 12px;
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 8px;
}

/* Status Badges (Pills) */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: var(--radius-pill);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.status-success {
    background: var(--status-ok-bg);
    color: #15803d;
}

/* Darker green text */
.status-warning {
    background: var(--status-warn-bg);
    color: #b45309;
}

.status-info {
    background: var(--status-info-bg);
    color: #1d4ed8;
}

.status-error {
    background: var(--status-deny-bg);
    color: #b91c1c;
}



/* Progress Bar */
.progress-bar {
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 999px;
    margin-top: 12px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--brand-accent);
    border-radius: 999px;
    transition: width 0.3s ease;
}

.progress-fill.complete {
    background: var(--status-ok);
}

.progress-fill.overcapacity {
    background: var(--status-deny);
}

.progress-fill.over-capacity {
    background: var(--status-deny) !important;
}

/* ==================== LOADING & EMPTY ==================== */
.loading,
.empty-state {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
}

/* ==================== COLLAPSIBLE PRODUCTS ==================== */
.products-collapsible summary::-webkit-details-marker {
    display: none;
}

.products-collapsible summary {
    list-style: none;
    outline: none;
    transition: background-color 0.2s;
}

.products-collapsible summary:hover {
    background-color: var(--bg-tertiary);
    opacity: 0.9;
}

.products-collapsible[open] .toggle-icon {
    transform: rotate(180deg);
}

.products-collapsible .toggle-icon {
    transition: transform 0.2s;
    font-size: 10px;
}

/* ==================== COLLAPSIBLE NOTES ==================== */
.notes-collapsible summary::-webkit-details-marker {
    display: none;
}

.notes-collapsible summary {
    list-style: none;
    outline: none;
    transition: background-color 0.2s;
}

.notes-collapsible summary:hover {
    opacity: 0.9;
}

.notes-collapsible[open] .toggle-icon {
    transform: rotate(90deg);
}

.notes-collapsible .toggle-icon {
    transition: transform 0.2s;
    display: inline-block;
}

/* ==================== REFRESH BUTTON ==================== */
@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.refreshing {
    opacity: 0.7;
    cursor: default;
}

/* ==================== FLOORPLAN SCREEN ==================== */
.floorplan-departure-selector {
    margin-bottom: var(--spacing-md);
}

.floorplan-date-picker {
    font-family: var(--font-family);
    font-size: 13px;
    font-weight: 500;
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid var(--border-subtle);
    background: var(--bg-secondary);
    color: var(--brand-accent);
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
    margin-top: 4px;
}

.floorplan-date-picker:focus {
    outline: none;
    border-color: var(--brand-accent);
    box-shadow: 0 0 0 2px rgba(15, 163, 161, 0.15);
}



.floorplan-departure-selector select {
    margin-bottom: 0;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%235B6777' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 40px;
}

.floorplan-container {
    background: var(--bg-secondary);
    border-radius: var(--radius-card);
    border: 1px solid var(--border-subtle);
    overflow: hidden;
    min-height: 400px;
    position: relative;
}

.floorplan-container iframe {
    width: 100%;
    height: calc(100vh - 320px);
    min-height: 400px;
    border: none;
    display: block;
}

.floorplan-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-md);
    padding: var(--spacing-xl);
    min-height: 300px;
    color: var(--text-muted);
    text-align: center;
}

.floorplan-placeholder p {
    font-size: 14px;
    max-width: 240px;
}

.floorplan-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-md);
    padding: var(--spacing-xl);
    min-height: 300px;
    color: var(--text-muted);
}

.floorplan-loading .spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border-subtle);
    border-top-color: var(--brand-accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.floorplan-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-xl);
    min-height: 300px;
    color: var(--status-deny);
    text-align: center;
    font-size: 14px;
}

/* ==================== DESKTOP LAYOUT ==================== */
@media (min-width: 768px) {

    /* -- Top Header Bar -- */
    .screen-header {
        display: flex;
        align-items: center;
        gap: 16px;
        padding-bottom: var(--spacing-lg);
        border-bottom: 1px solid var(--border-subtle);
        margin-bottom: var(--spacing-lg);
    }

    /* -- App Shell: sidebar + content -- */
    #app {
        display: flex;
        flex-direction: row;
        min-height: 100vh;
    }

    /* -- Sidebar Navigation -- */
    .bottom-nav {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        right: auto;
        width: 220px;
        flex-direction: column;
        justify-content: flex-start;
        padding: var(--spacing-xl) var(--spacing-md);
        padding-top: 32px;
        border-top: none;
        border-right: 1px solid var(--border-subtle);
        background: var(--bg-primary);
        box-shadow: 1px 0 3px rgba(0, 0, 0, 0.04);
        gap: 4px;
        overflow-y: auto;
        z-index: 100;
    }

    .nav-item {
        flex-direction: row;
        justify-content: flex-start;
        min-width: auto;
        width: 100%;
        gap: 12px;
        padding: 10px 14px;
        border-radius: var(--radius-button);
        transition: background 0.15s, color 0.2s;
    }

    .nav-item:hover {
        background: var(--bg-tertiary);
    }

    .nav-item.active {
        background: var(--status-info-bg);
        color: var(--brand-primary);
    }

    .nav-item span {
        font-size: 14px;
        font-weight: 500;
    }

    .nav-icon {
        width: 20px;
        height: 20px;
        flex-shrink: 0;
    }

    /* -- Sidebar Logo -- */
    .sidebar-logo {
        display: block;
        width: 160px;
        max-height: 40px;
        object-fit: contain;
        margin: 0 auto 20px auto;
    }

    /* -- Hide scanner header logo on desktop -- */
    .scanner-header-logo {
        display: none;
    }

    /* -- Content Area -- */
    .screen {
        flex: 1;
        max-width: none;
        width: calc(100% - 220px);
        margin: 0;
        margin-left: 220px;
        padding: var(--spacing-xl) 40px;
        padding-bottom: 40px;
        min-height: 100vh;
        background: var(--bg-tertiary);
    }

    body {
        background-color: var(--bg-tertiary);
        padding-bottom: 0;
    }

    /* -- Cards and containers inside screens -- */
    .scanner-container,
    .manual-input,
    .ship-toggle,
    #stats-container,
    .floorplan-container,
    .floorplan-departure-selector,
    .floorplan-ship-toggle {
        background: var(--bg-primary);
        border-radius: var(--radius-card);
        padding: var(--spacing-lg);
        box-shadow: var(--shadow-card);
        border: 1px solid var(--border-subtle);
        margin-bottom: var(--spacing-md);
    }

    .reservations-list {
        background: transparent;
        border-radius: 0;
        box-shadow: none;
        border: none;
    }

    .history-list {
        background: transparent;
        border-radius: 0;
        box-shadow: none;
        border: none;
    }

    /* -- Reservation cards standalone -- */
    .reservation-card {
        border-radius: var(--radius-card);
        box-shadow: var(--shadow-card);
        border: 1px solid var(--border-subtle);
        margin-bottom: var(--spacing-sm);
        width: 100%;
    }

    .reservation-card:last-child {
        margin-bottom: 0;
    }

    /* -- History cards standalone -- */
    .history-card {
        border-radius: var(--radius-card);
        margin-bottom: var(--spacing-sm);
    }

    .history-card:last-child {
        margin-bottom: 0;
    }

    /* -- Modal tweaks -- */
    .modal-content {
        max-width: 520px;
    }

    /* -- Header logo sizing for desktop -- */
    .header-logo {
        width: 180px;
        max-height: 44px;
    }

    /* -- Search bar full width in card -- */
    #reservation-search {
        max-width: none;
    }
}