/*
 | School colour themes for the main content area.
 | The navy sidebar is the same in every theme.
 | The school picks a theme on Settings → School branding; it is written on <html data-theme="…">.
 |   sky   – Sky Blue & Sunshine (default)
 |   sunny – Sunny Yellow & Cream
 |   coral – Coral & Peach
 | Plain CSS (not built by Vite), loaded after app.css, so these values win.
 */

/* ---------------------------------------------------------------- light */
html[data-theme="sky"] {
    --app-canvas: #eef6ff;
    --app-card-muted: #f2f8ff;
    --app-series: #0ea5e9;
    --color-accent: #ffc61a;
    --color-accent-foreground: #182d73;
    --color-accent-content: #1d6fd8;
    --erp-hero: linear-gradient(120deg, #2563eb, #0ea5e9);
    --erp-hero-text: #ffffff;
    --erp-c1: #38bdf8;
    --erp-c2: #ffc61a;
    --erp-c3: #22c55e;
    --erp-icon-bg: #dcebff;
    --erp-icon-fg: #1d6fd8;
}

html[data-theme="sunny"] {
    --app-canvas: #fffbef;
    --app-card-muted: #fff7dd;
    --app-series: #ffc61a;
    --color-accent: #ffc61a;
    --color-accent-foreground: #182d73;
    --color-accent-content: #182d73;
    --erp-hero: linear-gradient(120deg, #ffe58a, #ffc61a);
    --erp-hero-text: #182d73;
    --erp-c1: #ffc61a;
    --erp-c2: #1f3a8f;
    --erp-c3: #ff8a65;
    --erp-icon-bg: #fff3c4;
    --erp-icon-fg: #182d73;
}

html[data-theme="coral"] {
    --app-canvas: #fff6f2;
    --app-card-muted: #fff0ea;
    --app-series: #ff7a59;
    --color-accent: #e2553a;
    --color-accent-foreground: #ffffff;
    --color-accent-content: #d9481f;
    --erp-hero: linear-gradient(120deg, #f2643d, #e2475a);
    --erp-hero-text: #ffffff;
    --erp-c1: #ff7a59;
    --erp-c2: #ffb38a;
    --erp-c3: #1f3a8f;
    --erp-icon-bg: #ffe8df;
    --erp-icon-fg: #d9481f;
}

/* ---------------------------------------------------------------- dark (canvas stays deep navy) */
html.dark[data-theme] {
    --app-canvas: #0b1126;
    --app-card-muted: #1b2547;
    --erp-icon-bg: rgb(255 255 255 / 0.07);
}

html.dark[data-theme="sky"] {
    --app-series: #38bdf8;
    --color-accent: #ffc61a;
    --color-accent-foreground: #13245e;
    --color-accent-content: #7dd3fc;
    --erp-hero: linear-gradient(120deg, #1d4ed8, #0369a1);
    --erp-icon-fg: #7dd3fc;
}

html.dark[data-theme="sunny"] {
    --app-series: #ffd34d;
    --color-accent: #ffc61a;
    --color-accent-foreground: #13245e;
    --color-accent-content: #ffd34d;
    --erp-hero: linear-gradient(120deg, #3a3110, #6b5200);
    --erp-hero-text: #fff4cc;
    --erp-icon-fg: #ffd34d;
}

html.dark[data-theme="coral"] {
    --app-series: #ff8a65;
    --color-accent: #ff8a65;
    --color-accent-foreground: #2a0e05;
    --color-accent-content: #ffb199;
    --erp-hero: linear-gradient(120deg, #9a3412, #9f1239);
    --erp-icon-fg: #ffb199;
}

/* ---------------------------------------------------------------- shared pieces */
html[data-theme] .app-icon-btn {
    background-color: var(--erp-icon-bg);
    color: var(--erp-icon-fg);
}

/* Welcome banner on dashboards (x-page-header hero) */
.erp-hero {
    background: var(--erp-hero, linear-gradient(120deg, #2563eb, #0ea5e9));
    color: var(--erp-hero-text, #fff);
    border-radius: 18px;
    padding: 22px 26px;
    margin-bottom: 24px;
    display: flex;
    flex-wrap: wrap;
    gap: 12px 20px;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 6px 20px rgb(19 36 94 / 0.12);
}

.erp-hero [data-flux-heading],
.erp-hero [data-flux-subheading],
.erp-hero [data-flux-text] {
    color: inherit !important;
}

.erp-hero [data-flux-subheading] {
    opacity: 0.88;
}

.erp-hero-badge {
    background: rgb(255 255 255 / 0.25);
    border-radius: 999px;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
}

@media (max-width: 639.98px) {
    .erp-hero {
        padding: 18px;
        border-radius: 16px;
    }

    .erp-hero-badge {
        display: none;
    }
}

/* Coloured top stripe on dashboard cards (only on pages that show the banner) */
div:has(> .erp-hero) .grid > [data-flux-card]:nth-child(3n + 1),
div:has(> .erp-hero) .grid > :not([data-flux-card]):nth-child(3n + 1) > [data-flux-card] {
    border-top: 4px solid var(--erp-c1) !important;
}

div:has(> .erp-hero) .grid > [data-flux-card]:nth-child(3n + 2),
div:has(> .erp-hero) .grid > :not([data-flux-card]):nth-child(3n + 2) > [data-flux-card] {
    border-top: 4px solid var(--erp-c2) !important;
}

div:has(> .erp-hero) .grid > [data-flux-card]:nth-child(3n + 3),
div:has(> .erp-hero) .grid > :not([data-flux-card]):nth-child(3n + 3) > [data-flux-card] {
    border-top: 4px solid var(--erp-c3) !important;
}

/* ---------------------------------------------------------------- mobile bottom tab bar */
.erp-tabbar {
    display: none;
}

@media (max-width: 1023.98px) {
    .erp-tabbar {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 9;
        display: flex;
        align-items: stretch;
        justify-content: space-around;
        height: calc(62px + env(safe-area-inset-bottom));
        padding-bottom: env(safe-area-inset-bottom);
        background: var(--app-card);
        border-top: 1px solid rgb(19 36 94 / 0.08);
        box-shadow: 0 -4px 16px rgb(19 36 94 / 0.06);
    }

    .dark .erp-tabbar {
        border-top-color: rgb(255 255 255 / 0.06);
    }

    [data-flux-main] {
        padding-bottom: 90px !important;
    }
}

.erp-tab {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 0 2px;
    font-size: 10.5px;
    line-height: 1.1;
    color: var(--color-zinc-500);
    background: none;
    border: 0;
    cursor: pointer;
}

.erp-tab > span {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.erp-tab svg {
    width: 22px;
    height: 22px;
}

.erp-tab.is-active {
    color: var(--color-accent-content);
    font-weight: 600;
}

.erp-tab-menu [data-flux-button] {
    width: 36px !important;
    height: 30px !important;
    color: var(--color-zinc-500) !important;
}

/* ---------------------------------------------------------------- theme picker (Settings → School branding) */
.erp-theme-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 12px;
}

.erp-theme-option {
    position: relative;
    display: block;
    cursor: pointer;
    border-radius: 14px;
    padding: 10px;
    background: var(--app-card);
    border: 2px solid var(--color-zinc-200);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.erp-theme-option:hover {
    border-color: var(--color-zinc-400);
}

.erp-theme-option.is-selected {
    border-color: var(--color-navy-600);
    box-shadow: 0 0 0 3px rgb(31 58 143 / 0.15);
}

.dark .erp-theme-option.is-selected {
    border-color: var(--color-sunny-500);
}

.erp-theme-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.erp-theme-preview {
    display: flex;
    height: 84px;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid rgb(0 0 0 / 0.06);
}

.erp-theme-preview .side {
    width: 22%;
    background: #182d73;
}

.erp-theme-preview .body {
    flex: 1;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.erp-theme-preview .banner {
    height: 22px;
    border-radius: 6px;
}

.erp-theme-preview .cards {
    flex: 1;
    display: flex;
    gap: 5px;
}

.erp-theme-preview .cards i {
    flex: 1;
    background: #fff;
    border-radius: 5px;
    border-top: 3px solid;
}

.erp-theme-preview .btn {
    width: 34px;
    height: 9px;
    border-radius: 4px;
}

.erp-theme-name {
    margin-top: 8px;
    font-size: 13.5px;
    font-weight: 600;
}

.erp-theme-desc {
    font-size: 12px;
    color: var(--color-zinc-500);
}

.erp-theme-check {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 22px;
    height: 22px;
    border-radius: 999px;
    background: var(--color-navy-600);
    color: #fff;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
}

.erp-theme-option.is-selected .erp-theme-check {
    display: flex;
}
