/* ============================================================================
   Tharsol Connect theme: the TMS portal look (tms-tokens.css) as the parent of webmail's design tokens.

   Two settings decide what a page looks like (Settings -> Appearance, and the switch in the title bar):
     · the look, <html data-look>: absent or "connect" = Tharsol Connect (this file, the default);
       "classic" = the Tharsol Mail look exactly as webmail has it (tokens.css alone).
     · the mode, <html data-theme>: "dark" (the default, like the TMS portal), "light", or absent = match the
       device. Light and dark come from tokens.css / tms-tokens.css as before.

   Components keep using only webmail's variables (--bg, --surface, --accent, ...). This file points them at the
   TMS tokens, so every existing screen takes the TMS look without being touched. Note colours, file-type labels
   and the sign-in shapes keep webmail's values (they have no TMS counterpart).
   ========================================================================== */

/* TMS has no "match device" mode (its dark is opt-in), so its dark block is repeated here for a page with no
   data-theme on a device in dark mode. Keep in step with :root[data-theme="dark"] in tms-tokens.css. */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) {
        --tms-bg: #141319;
        --tms-surface: #1C1B23;
        --tms-surface-2: #24232D;
        --tms-surface-3: #2D2B38;
        --tms-border: #2E2C39;
        --tms-border-strong: #413E51;
        --tms-text: #E9E8EF;
        --tms-text-2: #A3A0B0;
        --tms-text-3: #918EA0;
        --tms-accent: #31B0A3;
        --tms-accent-dark: #49C6B9;
        --tms-accent-tint: #12332F;
        --tms-accent-line: #2A6A64;
        --tms-accent-ink-2: #31B0A3;
        --tms-on-accent: #06201D;
        --tms-on-danger: #1F0D0D;
        --tms-rail: #100F15;
        --tms-rail-2: #1F1D28;
        --tms-rail-text: #8E8A9C;
        --tms-rail-hover: #2E2B3B;
        --tms-rail-active-bg: rgba(49, 176, 163, .15);
        --tms-rail-active-line: rgba(49, 176, 163, .70);
        --tms-danger: #E87C7C; --tms-danger-tint: #37201F; --tms-danger-line: #5E3434;
        --tms-warn: #D6A44E; --tms-warn-tint: #332818; --tms-warn-line: #59431F;
        --tms-ok: #5FBB86; --tms-ok-tint: #173023; --tms-ok-line: #2C5540;
        --tms-info: #79A8DD; --tms-info-tint: #1A2635; --tms-info-line: #31496A;
        --tms-progress: #A78FD8; --tms-progress-tint: #231D33; --tms-progress-line: #42375F;
        --tms-mood-neg: #D85F5C; --tms-mood-pos: #5B8FCB;
        --tms-shadow-1: 0 1px 2px rgba(0,0,0,.4);
        --tms-shadow-2: 0 4px 14px rgba(0,0,0,.45);
        --tms-shadow-3: 0 18px 48px rgba(0,0,0,.6);
    }
}

/* ---- webmail's variables on the TMS tokens (light, dark and match-device alike: the TMS tokens switch) ---- */
:root:not([data-look="classic"]) {
    --bg: var(--tms-bg);
    --surface: var(--tms-surface);
    --surface-2: var(--tms-surface-2);
    --border: var(--tms-border);
    --line: var(--tms-surface-2);
    --text: var(--tms-text);
    --muted: var(--tms-text-2);
    --faint: var(--tms-text-3);
    --accent: var(--tms-accent);
    --accent-text: var(--tms-on-accent);
    --soft: var(--tms-accent-tint);
    --hover: var(--tms-surface-2);
    --selected: var(--tms-accent-tint);
    --ok: var(--tms-ok);
    --ok-soft: var(--tms-ok-tint);
    --warn: var(--tms-warn);
    --warn-soft: var(--tms-warn-tint);
    --danger: var(--tms-danger);
    --radius-panel: var(--tms-r-lg);
    --radius-control: var(--tms-r);
    --font-sans: var(--tms-font);
    --login-a: var(--tms-accent-tint);
    --login-b: var(--tms-info-tint);
    --login-ring: var(--tms-accent-line);
}

/* ============================================================================
   The left rail, drawn like the TMS portal rail (Tms.Client Layout/NavRail.razor, tms-base.css "APP SHELL"):
   dark in both modes, every app on its own 42 x 38 tile with the accent bar on its left, the current one a
   tinted wash with an accent edge and a bright icon, separators between groups. Same items as webmail's rail.
   ========================================================================== */
:root:not([data-look="classic"]) .rail {
    width: var(--tms-rail-w);
    background: var(--tms-rail);
    gap: 2px;
    padding: 10px 0;
    border-radius: 0 var(--tms-r-lg) 0 0;
    margin-right: 8px;
}

    :root:not([data-look="classic"]) .rail a {
        position: relative;
        width: 42px;
        height: 38px;
        flex: none;
        border-radius: var(--tms-r);
        background: var(--tms-rail-2);
        color: var(--tms-rail-text);
        box-shadow: none;
        transition: background-color var(--tms-fast), color var(--tms-fast), box-shadow var(--tms-fast);
    }

        /* Every tile carries the accent bar on its left, at the rail's edge, as the portal's rail always has. */
        :root:not([data-look="classic"]) .rail a::before {
            content: "";
            position: absolute;
            left: -9px;
            top: 9px;
            bottom: 9px;
            width: 3px;
            border-radius: 0 3px 3px 0;
            background: var(--tms-rail-accent);
        }

        :root:not([data-look="classic"]) .rail a:hover {
            background: var(--tms-rail-hover);
            color: var(--tms-rail-ink, #fff);
        }

        :root:not([data-look="classic"]) .rail a.active,
        :root:not([data-look="classic"]) .rail a.active:hover {
            background: var(--tms-rail-active-bg);
            color: var(--tms-rail-active-ink);
            box-shadow: inset 0 0 0 1px var(--tms-rail-active-line);
        }

        :root:not([data-look="classic"]) .rail a .icon {
            width: 19px;
            height: 19px;
            stroke-width: 1.75;
        }

    /* Badges sit on the tile's corner drawn exactly as the ticket screens' rail draws its counts (Tms.Client
       tms-chat.css .tms-rail-badge), so the shared rail's badges look the same on both sides (phase 5). */
    :root:not([data-look="classic"]) .rail .mbadge,
    :root:not([data-look="classic"]) .rail .tbadge,
    :root:not([data-look="classic"]) .rail .cbadge,
    :root:not([data-look="classic"]) .rail .rbadge,
    :root:not([data-look="classic"]) .rail .tr-gbadge {
        top: 1px;
        right: 0;
        min-width: 17px;
        height: 17px;
        padding: 0 4px;
        border-radius: 999px;
        background: var(--tms-danger);
        color: var(--tms-on-danger);
        border: 2px solid var(--tms-rail);
        font-size: 10px;
        font-weight: 750;
        line-height: 13px;
        font-variant-numeric: tabular-nums;
        pointer-events: none;
    }

    /* Separators carry the grouping, visible enough to read as breaks (tms-base.css .tms-rail-sep). */
    :root:not([data-look="classic"]) .rail .rail-sep {
        display: block;
        width: 28px;
        height: 1px;
        background: rgba(255, 255, 255, .18);
        margin: 9px 0;
        flex: none;
    }

/* Phone: the rail is hidden (MainLayout.razor.css); the bottom tabs and More sheet take the accent as they are. */

/* Light theme: the rail is light too (user, 13 Oct 2026; the TMS portal kept it dark in both themes). Only the rails get
   these: TMS's own --tms-rail tokens stay dark where they paint other things (its login panel, the media viewer).
   The accent is the darker teal so the current tile keeps its contrast on the light surface. */
:root[data-theme="light"] :is(.rail, .tms-rail, nav.tabs) {
    --tms-rail: #EEF0F5;
    --tms-rail-2: #E3E6EE;
    --tms-rail-text: #545A6B;
    --tms-rail-ink: #1A1D26;
    --tms-rail-line: rgba(26, 29, 38, .12);
    --tms-rail-hover: #D9DDE8;
    --tms-rail-accent: #0F8F84;
    --tms-rail-accent-ink: #FFFFFF;
    --tms-rail-active-bg: rgba(15, 143, 132, .12);
    --tms-rail-active-line: rgba(15, 143, 132, .55);
    --tms-rail-active-ink: #0D6E68;
    border-right: 1px solid rgba(26, 29, 38, .08);
}

@media (prefers-color-scheme: light) {
    :root:not([data-theme]) :is(.rail, .tms-rail, nav.tabs) {
        --tms-rail: #EEF0F5;
        --tms-rail-2: #E3E6EE;
        --tms-rail-text: #545A6B;
        --tms-rail-ink: #1A1D26;
        --tms-rail-line: rgba(26, 29, 38, .12);
        --tms-rail-hover: #D9DDE8;
        --tms-rail-accent: #0F8F84;
        --tms-rail-accent-ink: #FFFFFF;
        --tms-rail-active-bg: rgba(15, 143, 132, .12);
        --tms-rail-active-line: rgba(15, 143, 132, .55);
        --tms-rail-active-ink: #0D6E68;
        border-right: 1px solid rgba(26, 29, 38, .08);
    }
}
