/* TUKLAS brand palette
 * Heritage Red: #EC090C | Deep Crimson: #A41617 | Warm Ivory: #FEEFEB
 *
 * This file is loaded after each layout's page CSS so it can consistently
 * apply the brand without losing readable surfaces or status colours.
 */

:root {
    --heritage-red: #EC090C;
    --heritage-red-rgb: 236, 9, 12;
    --deep-crimson: #A41617;
    --deep-crimson-rgb: 164, 22, 23;
    --warm-ivory: #FEEFEB;
    --warm-ivory-rgb: 254, 239, 235;

    /* Keep the original calm workspace canvas for comfortable reading. */
    --system-canvas: #E8E6F5;
    --system-surface: #FFFCFB;
    --system-border: #E5E1EF;
    --system-ink: #1A1A2E;
    --system-muted: #625B6B;
    --system-selection: #667085;

    /* Existing admin / teacher tokens. */
    --brand-primary: var(--heritage-red);
    --brand-primary-dark: var(--deep-crimson);
    --brand-secondary: var(--deep-crimson);
    --brand-accent: var(--heritage-red);
    --brand-pink: var(--deep-crimson);
    --brand-blue: var(--heritage-red);
    --gradient-brand: linear-gradient(135deg, var(--heritage-red) 0%, var(--deep-crimson) 100%);
    --gradient-hero: var(--gradient-brand);

    /* Dark crimson navigation: strong contrast without the old blue/purple hue. */
    --sidebar-bg: #6A0C10;
    --sidebar-text: rgba(255, 255, 255, 0.86);
    --sidebar-active-bg: rgba(var(--warm-ivory-rgb), 0.16);
    --sidebar-active: #FFFFFF;

    --content-bg: var(--system-canvas);
    --card-bg: rgba(255, 255, 255, 0.90);
    --card-shadow: 0 4px 24px rgba(15, 12, 41, 0.08);
    --text-heading: var(--system-ink);
    --text-body: #374151;
    --text-muted: var(--system-muted);

    /* Existing student tokens. */
    --student-primary: var(--heritage-red);
    --student-yellow: var(--warm-ivory);
    /* Success remains green rather than being repurposed as a brand colour. */
    --student-green: #198754;
    --student-pink: var(--deep-crimson);
    --student-blue: var(--heritage-red);
    --student-orange: var(--heritage-red);
    --gradient-student: var(--gradient-brand);

    /* Bootstrap tokens used by newer screens. */
    --bs-primary: var(--heritage-red);
    --bs-primary-rgb: var(--heritage-red-rgb);
    --bs-link-color: var(--heritage-red);
    --bs-link-color-rgb: var(--heritage-red-rgb);
    --bs-link-hover-color: var(--deep-crimson);
    --bs-link-hover-color-rgb: var(--deep-crimson-rgb);
    --bs-body-bg: var(--system-canvas);
    --bs-body-color: var(--system-ink);
    --bs-focus-ring-color: rgba(102, 112, 133, 0.22);
}

html,
body {
    background: var(--system-canvas);
    color: var(--system-ink);
}

::-webkit-scrollbar-thumb {
    background: rgba(102, 112, 133, 0.34);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--system-selection);
}

a { color: var(--heritage-red); }
a:hover { color: var(--deep-crimson); }

/* ── Dark, high-contrast sidebar ─────────────────────────────── */
.sidebar {
    background: var(--sidebar-bg);
    background-image: linear-gradient(180deg, #A41617 0%, #780D11 55%, #52080B 100%);
    box-shadow: 4px 0 30px rgba(var(--deep-crimson-rgb), 0.34);
}

.sidebar-brand-icon,
.sidebar-avatar,
.topbar-avatar {
    background: var(--gradient-brand);
    box-shadow: 0 4px 15px rgba(var(--heritage-red-rgb), 0.30);
}

.sidebar-brand-text,
.sidebar-user-name { color: #fff; }

.sidebar-brand-sub { color: rgba(255, 255, 255, 0.68); }
.sidebar-section-label { color: rgba(255, 255, 255, 0.56); }
.sidebar-user-role { color: rgba(255, 255, 255, 0.64); }
.sidebar-logout { color: rgba(255, 255, 255, 0.72); }
.sidebar-logout:hover { color: var(--warm-ivory); }

.sidebar-link { color: rgba(255, 255, 255, 0.86); }
.sidebar-link:hover { color: #fff; background: rgba(var(--warm-ivory-rgb), 0.12); }
.sidebar-link.active {
    color: #fff;
    background: var(--sidebar-active-bg);
    box-shadow: inset 3px 0 0 var(--warm-ivory);
}
.sidebar-badge { background: var(--heritage-red); }

/* ── Calm workspace and readable data ────────────────────────── */
.main-content,
.page-body,
.auth-form-panel { background: var(--system-canvas); }

.topbar {
    background: rgba(255, 255, 255, 0.92);
    border-bottom-color: var(--system-border);
    box-shadow: 0 2px 12px rgba(15, 12, 41, 0.06);
}

.text-muted { color: var(--system-muted) !important; }

.panel-card,
.stat-card,
.auth-card,
.story-card,
.student-empty,
.modal-content,
.builder-toolbar,
.workspace-left,
.workspace-right,
.scene-player-panel {
    border-color: var(--system-border) !important;
    box-shadow: 0 4px 20px rgba(15, 12, 41, 0.08);
}

.data-table thead th {
    background: #F6F4FC;
    color: #5B5564;
    border-bottom-color: var(--system-border);
}

.data-table tbody td { color: #374151; }
.data-table tbody tr:hover { background: rgba(var(--heritage-red-rgb), 0.035); }

/* ── Brand actions and common Bootstrap controls ─────────────── */
.btn-primary,
.btn-brand,
.bg-primary,
.bg-purple {
    color: #fff !important;
    background: var(--heritage-red) !important;
    border-color: var(--heritage-red) !important;
    background-image: none !important;
}

.btn-primary:hover,
.btn-primary:focus,
.btn-primary:active,
.btn-brand:hover,
.btn-brand:focus,
.btn-brand:active {
    color: #fff !important;
    background: var(--deep-crimson) !important;
    border-color: var(--deep-crimson) !important;
    box-shadow: 0 6px 18px rgba(var(--deep-crimson-rgb), 0.24) !important;
}

.btn-outline-primary,
.btn-outline-brand {
    color: var(--heritage-red) !important;
    background: transparent !important;
    border-color: var(--heritage-red) !important;
}

.btn-outline-primary:hover,
.btn-outline-primary:focus,
.btn-outline-brand:hover,
.btn-outline-brand:focus {
    color: #fff !important;
    background: var(--heritage-red) !important;
    border-color: var(--heritage-red) !important;
}

.text-primary,
.text-purple { color: var(--heritage-red) !important; }
.border-primary,
.border-purple { border-color: var(--heritage-red) !important; }
.bg-primary-subtle,
.bg-purple-light { background-color: rgba(var(--heritage-red-rgb), 0.08) !important; }

.nav-pills .nav-link.active,
.page-item.active .page-link,
.dropdown-item.active,
.dropdown-item:active {
    color: #fff !important;
    background-color: var(--system-selection) !important;
}

.page-link { color: var(--heritage-red); }
.page-link:hover { color: var(--deep-crimson); background-color: rgba(var(--heritage-red-rgb), 0.07); }

.form-control:focus,
.form-select:focus,
.form-check-input:focus {
    border-color: var(--system-selection) !important;
    box-shadow: 0 0 0 0.18rem rgba(102, 112, 133, 0.16) !important;
}

.form-check-input:checked {
    background-color: var(--system-selection) !important;
    border-color: var(--system-selection) !important;
}

.nav-tabs .nav-link.active,
.asset-tabs .nav-link.active {
    color: var(--system-ink) !important;
    border-bottom-color: var(--system-selection) !important;
}

.progress-bar,
.progress-bar-brand,
.story-progress-fill {
    background: var(--gradient-brand) !important;
}

.timeline-scene.active,
.stage-element.selected {
    border-color: var(--system-selection) !important;
    box-shadow: none !important;
}

.resize-handle { background: var(--system-selection) !important; }
.asset-actions button { background: var(--heritage-red) !important; }

.student-topbar,
.student-hero,
.auth-hero,
.quiz-header,
.mission-modal-header { background: var(--gradient-brand) !important; }

.student-topbar { box-shadow: 0 4px 20px rgba(var(--deep-crimson-rgb), 0.28); }
.student-hero::after { background: var(--system-canvas); }

.role-toggle input[type="radio"]:checked + label {
    background: var(--heritage-red) !important;
    box-shadow: 0 4px 12px rgba(var(--heritage-red-rgb), 0.28) !important;
}

.input-group-text,
.auth-toggle-link a,
.password-toggle:hover,
.error-code { color: var(--heritage-red) !important; }

.btn-back {
    color: #fff !important;
    background: var(--gradient-brand) !important;
}
