/* Vasbyt portal: palette and layout from spec section 10. All colours live in these variables so both themes switch from one place.
   Light is "Daylight", the client app's look: warm off-white, white cards with soft shadows, black main buttons. */

:root,
:root[data-theme="dark"] {
    --bg: #0E1424;
    --surface: #161D30;
    --surface-raised: #1D2640;
    --border: #26304A;
    --text: #E8ECF5;
    --text-muted: #8E98B3;
    --accent: #FF5A1F;
    --accent-hover: #FF7240;
    --accent-soft: rgba(255, 90, 31, 0.14);
    --accent-text: #FF5A1F;
    --on-accent: #FFFFFF;
    --primary: #FF5A1F;
    --primary-hover: #FF7240;
    --on-primary: #FFFFFF;
    --selected-bg: #FF5A1F;
    --selected-text: #FFFFFF;
    --card-border: #26304A;
    --shadow: none;
    --ok: #22C55E;
    --warn: #F5A524;
    --danger: #EF4444;
    --radius: 18px;
    --radius-sm: 12px;
    --sidebar-width: 236px;
    --panel-width: 300px;
    --font: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color-scheme: dark;

    /* DevExpress Fluent accent ramp (light → dark), centred on the Vasbyt orange at step 90. */
    --dxbl-accent-color-10: #FFEDE6;
    --dxbl-accent-color-20: #FFDACD;
    --dxbl-accent-color-30: #FFC8B4;
    --dxbl-accent-color-40: #FFB69B;
    --dxbl-accent-color-50: #FFA383;
    --dxbl-accent-color-60: #FF916A;
    --dxbl-accent-color-70: #FF7F51;
    --dxbl-accent-color-80: #FF6C38;
    --dxbl-accent-color-90: #FF5A1F;
    --dxbl-accent-color-100: #E4501C;
    --dxbl-accent-color-110: #C94718;
    --dxbl-accent-color-120: #AE3D15;
    --dxbl-accent-color-130: #933412;
    --dxbl-accent-color-140: #782A0F;
    --dxbl-accent-color-150: #5C210B;
    --dxbl-accent-color-160: #411708;
    --dxbl-accent-color-170: #260E05;
}

/* Dark mode only: tint the DevExpress Fluent greys towards the Vasbyt navy so grids and editors sit on the same surfaces as our cards. */
:root:not([data-theme="light"]) {
    --DS-neutral-100: #8E98B3;
    --DS-neutral-110: #6E7894;
    --DS-neutral-120: #4A5573;
    --DS-neutral-130: #3A4562;
    --DS-neutral-140: #26304A;
    --DS-neutral-150: #1D2640;
    --DS-neutral-160: #161D30;
    --DS-neutral-170: #0E1424;
}

:root[data-theme="light"] {
    --bg: #F4F2EE;
    --surface: #FFFFFF;
    --surface-raised: #F4F2EE;
    --border: #E6E2DA;
    --text: #16181D;
    --text-muted: #5E6470;
    --accent-soft: #FFF1EA;
    --accent-text: #B83A06;
    --primary: #16181D;
    --primary-hover: #2E323B;
    --on-primary: #FFFFFF;
    --selected-bg: #FFF1EA;
    --selected-text: #B83A06;
    --ok: #17663A;
    --warn: #B45309;
    --danger: #C62828;
    --card-border: transparent;
    --shadow: 0 1px 2px rgba(22, 24, 29, 0.06), 0 8px 24px rgba(22, 24, 29, 0.06);
    color-scheme: light;
}

/* Daylight: DevExpress grids, editors and popups sit on the same warm greys and white cards. */
:root[data-theme="light"] .dxbl-grid,
:root[data-theme="light"] .dxbl-popup-content,
:root[data-theme="light"] .dxbl-modal-content { border-radius: var(--radius); }
:root[data-theme="light"] .nav-item.active .nav-badge { background: var(--accent); color: var(--on-accent); }

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

html, body {
    margin: 0;
    min-height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 1.6rem; font-weight: 700; }
h1:focus { outline: none; }
a { color: var(--accent-text); }

.muted { color: var(--text-muted); }
.small { font-size: 0.85rem; }
.accent { color: var(--accent-text); }
.icon { flex-shrink: 0; }

/* ---------- Shell ---------- */

.shell {
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
    min-height: 100vh;
}

.shell:not(.panel-toggled) { grid-template-columns: var(--sidebar-width) minmax(0, 1fr) var(--panel-width); }

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding: 20px 14px;
    background: var(--surface);
    border-right: 1px solid var(--border);
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 8px;
    color: var(--text);
    text-decoration: none;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    background: var(--accent);
    color: var(--on-accent);
    font-weight: 800;
}

.brand-name { font-size: 1.2rem; font-weight: 800; letter-spacing: -0.01em; }

.nav { display: flex; flex-direction: column; gap: 4px; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-weight: 500;
    text-decoration: none;
}

.nav-item:hover { background: var(--surface-raised); color: var(--text); }
.nav-item.active { background: var(--selected-bg); color: var(--selected-text); font-weight: 700; }

.main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 6px;
    height: 64px;
    padding: 0 24px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}

.topbar-spacer { flex: 1; }
.logout-form { margin: 0; }

.icon-button {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
}

.icon-button:hover { background: var(--surface-raised); color: var(--text); }
.icon-button:focus-visible, .button:focus-visible, .nav-item:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.nav-toggle { display: none; }

.user-chip { padding: 0 6px; }

.avatar {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--surface-raised);
    border: 1px solid var(--border);
    font-size: 0.8rem;
    font-weight: 700;
}

.content {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 28px 24px 40px;
    max-width: 1280px;
    width: 100%;
}

.side-panel {
    display: none;
    flex-direction: column;
    gap: 16px;
    padding: 20px 16px;
    border-left: 1px solid var(--border);
}

.shell:not(.panel-toggled) .side-panel { display: flex; }

.scrim { display: none; }

/* ---------- Cards and content ---------- */

.page-header { display: flex; flex-direction: column; gap: 4px; }
.page-header p { margin: 0; }

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

.card-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    font-size: 1rem;
    font-weight: 600;
}

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

.kpi { display: flex; flex-direction: column; gap: 8px; }
.kpi-label { color: var(--text-muted); font-size: 0.85rem; font-weight: 500; }
.kpi-value { font-size: 2rem; font-weight: 800; letter-spacing: -0.02em; }

.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
    gap: 16px;
}

.attention { border-color: var(--accent-soft); }

.empty-state {
    padding: 18px;
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    text-align: center;
}

.empty-state p { margin: 0; }
.empty-state p + p { margin-top: 4px; }

/* ---------- Buttons and forms ---------- */

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 42px;
    padding: 0 18px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}

.button.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.button.primary:hover { background: var(--primary-hover); }
.button.block { width: 100%; }

.form { display: flex; flex-direction: column; gap: 16px; margin-top: 20px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-weight: 500; }

.form input:not([class*="dxbl"]):not([type="checkbox"]):not([type="color"]) {
    height: 44px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text);
    font: inherit;
}

.form input:not([class*="dxbl"]):not([type="checkbox"]):focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }

.validation-message, .form-error { color: var(--danger); font-size: 0.85rem; font-weight: 500; }
.form-error { margin: 16px 0 0; padding: 10px 12px; border-radius: var(--radius-sm); background: rgba(239, 68, 68, 0.12); }

.center-page {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 16px;
}

.narrow { width: 100%; max-width: 400px; }
.narrow h1 { margin-bottom: 4px; }
.narrow .button { margin-top: 16px; }
.login-brand { padding: 0; margin-bottom: 24px; }

/* ---------- Page furniture ---------- */

.page-header.row { flex-direction: row; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.header-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.back-link { color: var(--text-muted); font-size: 0.85rem; text-decoration: none; }
.back-link:hover { color: var(--text); }
.sub-heading { margin: 20px 0 8px; font-size: 0.95rem; font-weight: 600; }
.button.small { min-height: 32px; padding: 0 12px; font-size: 0.85rem; }
.button.link { border: 0; background: none; color: var(--accent-text); padding: 0; min-height: 0; margin-top: 8px; }
.icon-button.small { width: 30px; height: 30px; font-size: 0.7rem; }
.form-saved { margin: 0; color: var(--ok); font-weight: 600; }
.checkbox { display: inline-flex !important; flex-direction: row !important; align-items: center; gap: 8px; cursor: pointer; }
.checkbox input { width: 18px; height: 18px; accent-color: var(--accent); }

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

/* ---------- Settings ---------- */

.tab-body { padding-top: 16px; }
.settings-tabs .sub-tabs { margin-top: 4px; }
.settings-form { max-width: 760px; margin-top: 0; }
.row-move { display: flex; gap: 4px; }
.colour-input { display: flex; gap: 8px; align-items: center; }
.colour-input input[type="color"] { width: 44px; height: 44px; padding: 2px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg); }
.colour-input input:not([type="color"]) { flex: 1; }
.logo-row { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.logo-preview {
    display: grid;
    place-items: center;
    width: 160px;
    height: 96px;
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-raised);
}
.logo-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }

/* ---------- Exercises ---------- */

.filter-bar {
    display: grid;
    grid-template-columns: minmax(180px, 2fr) repeat(4, minmax(140px, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}

.thumb { display: grid; place-items: center; width: 56px; height: 40px; border-radius: 8px; object-fit: cover; background: var(--surface-raised); color: var(--text-muted); }
.exercise-grid .dxbl-grid-table tr { cursor: pointer; }
.row-inactive { opacity: 0.5; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

.exercise-editor { display: flex; flex-direction: column; gap: 20px; }
.exercise-editor .card.form { margin-top: 0; gap: 14px; }
.exercise-editor .card-title { margin-bottom: 0; }

.segmented { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg); width: fit-content; }
.segmented button { border: 0; border-radius: 8px; padding: 8px 14px; background: transparent; color: var(--text-muted); font: inherit; font-weight: 600; cursor: pointer; }
.segmented button.selected { background: var(--selected-bg); color: var(--selected-text); }

.video-preview { width: 100%; max-width: 480px; border-radius: var(--radius-sm); background: #000; }
.video-embed { display: block; aspect-ratio: 16 / 9; border: 0; }
.media-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 24px; }
.image-list { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.image-tile { position: relative; margin: 0; width: 120px; height: 90px; }
.image-tile img { width: 100%; height: 100%; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.image-tile .icon-button { position: absolute; top: 4px; right: 4px; background: rgba(0, 0, 0, 0.6); color: #fff; }

.field-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.field-row { display: flex; align-items: center; gap: 8px; min-height: 48px; padding: 6px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.field-row.on { border-color: var(--accent); background: var(--accent-soft); }
.field-row .checkbox { flex: 1; font-weight: 500; }
.form .field-default { width: 80px !important; height: 34px !important; }

.sticky-actions {
    position: sticky;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 16px;
    padding: 14px 0;
    background: linear-gradient(transparent, var(--bg) 30%);
}

.phone-frame {
    max-height: 70vh;
    overflow-y: auto;
    padding: 12px;
    border: 8px solid #16181D;
    border-radius: 28px;
    background: var(--bg);
}

/* ---------- Responsive ---------- */

@media (max-width: 1200px) {
    .shell:not(.panel-toggled) { grid-template-columns: var(--sidebar-width) minmax(0, 1fr); }
    .shell:not(.panel-toggled) .side-panel { display: none; }

    .panel-toggled .side-panel {
        display: flex;
        position: fixed;
        top: 64px;
        right: 0;
        bottom: 0;
        z-index: 4;
        width: var(--panel-width);
        background: var(--bg);
        overflow-y: auto;
    }
}

@media (max-width: 900px) {
    .shell, .shell:not(.panel-toggled) { grid-template-columns: minmax(0, 1fr); }

    .sidebar {
        position: fixed;
        left: 0;
        z-index: 20;
        width: var(--sidebar-width);
        transform: translateX(-100%);
        transition: transform 0.2s ease;
    }

    .nav-open .sidebar { transform: none; }
    .nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 10; background: rgba(0, 0, 0, 0.5); }
    .nav-toggle { display: grid; }
    .topbar, .content { padding-left: 16px; padding-right: 16px; }
    .dashboard-grid { grid-template-columns: minmax(0, 1fr); }
    .panel-toggled .side-panel { width: min(var(--panel-width), 100vw); }
    .filter-bar { grid-template-columns: 1fr 1fr; }
    .filter-bar .filter-search { grid-column: 1 / -1; }
}

/* ---------- Blazor error UI (from the template) ---------- */

#blazor-error-ui {
    background: lightyellow;
    color: #141A2E;
    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; }

.blazor-error-boundary { background: #b32121; padding: 1rem; color: white; }
.blazor-error-boundary::after { content: "An error has occurred."; }

/* Daylight: DevExpress's own primary buttons (upload, dialogs) use the same black pill as ours instead of the orange accent. */
:root[data-theme="light"] .dxbl-btn {
    --dxbl-btn-primary-bg: var(--primary);
    --dxbl-btn-primary-border-color: var(--primary);
    --dxbl-btn-primary-color: var(--on-primary);
    --dxbl-btn-primary-hover-bg: var(--primary-hover);
    --dxbl-btn-primary-hover-border-color: var(--primary-hover);
    --dxbl-btn-primary-active-bg: #000000;
    --dxbl-btn-primary-active-border-color: #000000;
}
.file-upload .dxbl-btn { border-radius: 999px; padding-inline: 16px; font-weight: 700; }
