/* ==========================================================================
   console.css — theme + layout for the new staff console (apps.console).

   Deliberately scoped to `.console-shell` (the <body> class on every
   console/*.html page) rather than editing root.css/dashboard.css directly:
   those two still drive the public landing page and the legacy /central/
   dashboard, which keep their existing magenta/gold/cyan brand palette.

   Colors below are ported from the SvelteKit frontend's palette
   (frontend/src/app.css, itself layered on the sv5ui theme) so the Django
   console and the Svelte user dashboard read as the same product, as
   requested. Kept as an override layer (not a root.css rewrite) so it can
   be revisited/undone in one file if the frontend palette changes.
   ========================================================================== */

html[data-bs-theme="light"] .console-shell {
    --color-primary: oklch(0.52 0.12 200);
    --color-primary-75: oklch(0.52 0.12 200 / 75%);
    --color-primary-50: oklch(0.52 0.12 200 / 50%);
    --color-primary-25: oklch(0.52 0.12 200 / 25%);

    --color-secondary: oklch(0.44 0.08 310);
    --color-secondary-75: oklch(0.44 0.08 310 / 75%);
    --color-secondary-50: oklch(0.44 0.08 310 / 50%);
    --color-secondary-25: oklch(0.44 0.08 310 / 25%);

    --color-tertiary: oklch(0.56 0.10 85);
    --color-tertiary-75: oklch(0.56 0.10 85 / 75%);
    --color-tertiary-50: oklch(0.56 0.10 85 / 50%);
    --color-tertiary-25: oklch(0.56 0.10 85 / 25%);

    --bg: oklch(0.985 0.002 247);
    --surface: oklch(1 0 0);
    --surface-alt: oklch(0.968 0.006 247);
    --surface-raised: oklch(0.956 0.008 247);
    --text: oklch(0.16 0.014 247);
    --text-muted: oklch(0.44 0.04 257);
    --border: oklch(0.79 0.03 256);

    --header-bg: oklch(0.976 0.004 247);
    --header-text: oklch(0.16 0.014 247);
    --link: var(--color-primary);

    --success: oklch(0.60 0.15 145);
    --error: oklch(0.58 0.19 25);
    --severity-info: var(--color-primary);
    --severity-warning: oklch(0.68 0.15 65);
    --severity-critical: oklch(0.58 0.19 25);
}

html[data-bs-theme="dark"] .console-shell {
    --color-primary: oklch(0.72 0.16 196);
    --color-primary-75: oklch(0.72 0.16 196 / 75%);
    --color-primary-50: oklch(0.72 0.16 196 / 50%);
    --color-primary-25: oklch(0.72 0.16 196 / 25%);

    --color-secondary: oklch(0.70 0.22 307);
    --color-secondary-75: oklch(0.70 0.22 307 / 75%);
    --color-secondary-50: oklch(0.70 0.22 307 / 50%);
    --color-secondary-25: oklch(0.70 0.22 307 / 25%);

    --color-tertiary: oklch(0.82 0.17 85);
    --color-tertiary-75: oklch(0.82 0.17 85 / 75%);
    --color-tertiary-50: oklch(0.82 0.17 85 / 50%);
    --color-tertiary-25: oklch(0.82 0.17 85 / 25%);

    --bg: oklch(0.14 0.018 264);
    --surface: oklch(0.17 0.018 264);
    --surface-alt: oklch(0.20 0.020 264);
    --surface-raised: oklch(0.24 0.022 264);
    --text: oklch(0.93 0.010 255);
    --text-muted: oklch(0.70 0.025 255);
    --border: oklch(0.32 0.022 264);

    --header-bg: oklch(0.10 0.015 264);
    --header-text: oklch(0.93 0.010 255);
    --link: var(--color-primary);

    --success: oklch(0.72 0.18 145);
    --error: oklch(0.65 0.20 25);
    --severity-info: var(--color-primary);
    --severity-warning: oklch(0.78 0.17 65);
    --severity-critical: oklch(0.65 0.20 25);
}

/* Bootstrap variable remap (same technique as dashboard.css) so built-in
   components pick up the ported palette automatically. */
html[data-bs-theme] .console-shell {
    --bs-body-font-family: var(--font-sans);
    --bs-body-bg: var(--bg);
    --bs-body-color: var(--text);
    --bs-border-color: var(--border);
    --bs-border-color-translucent: var(--border);
    --bs-secondary-bg: var(--surface-alt);
    --bs-tertiary-bg: var(--surface-alt);
    --bs-emphasis-color: var(--text);
    --bs-link-color: var(--link);
    --bs-link-hover-color: var(--color-primary);
    --bs-primary: var(--color-primary);
    --bs-primary-text-emphasis: var(--color-primary);
    --bs-primary-bg-subtle: var(--color-primary-25);
    --bs-primary-border-subtle: var(--color-primary-50);
    --bs-table-bg: var(--surface);
    --bs-table-color: var(--text);
    --bs-table-border-color: var(--border);
    --bs-table-striped-bg: var(--surface-alt);
    --bs-table-hover-bg: var(--color-primary-25);
}

.console-shell {
    transition: background var(--transition-medium), color var(--transition-medium);
}

/* ---------------------------------------------------------------------- */
/* Sidebar shell layout                                                    */
/* ---------------------------------------------------------------------- */
.console-layout {
    display: flex;
    min-height: 100vh;
}

/* The sidebar is its own fixed-position UI element (not part of the normal
   document flow) so it keeps its own scrollbar and never scrolls with the
   main content. It's off-screen by default and slid into view with a
   transform; from the lg breakpoint up it's always visible. */
.console-sidebar {
    width: 240px;
    flex-shrink: 0;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1045;
    overflow-y: auto;
    background: var(--header-bg);
    color: var(--header-text);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: var(--space-md) var(--space-sm);
    transform: translateX(-100%);
    transition: transform var(--transition-medium);
}

.console-sidebar.show {
    transform: translateX(0);
}

@media (min-width: 992px) {
    .console-sidebar {
        transform: none;
    }
}

.console-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-sm);
    padding: 0 var(--space-sm) var(--space-md);
}

.console-sidebar .brand {
    color: var(--header-text);
    text-decoration: none;
    font-weight: 600;
    font-size: 1.05rem;
}

.console-nav-group {
    margin-bottom: var(--space-md);
}

.console-nav-group-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-muted);
    padding: 0 var(--space-sm);
    margin-bottom: var(--space-xs);
}

.console-nav-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border-radius: var(--radius-sm);
    color: inherit;
    text-decoration: none;
    font-size: 14px;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.console-nav-link:hover {
    background: var(--color-primary-25);
    color: var(--color-primary);
}

.console-nav-link.active {
    background: var(--color-primary-25);
    color: var(--color-primary);
    font-weight: 600;
}

.console-nav-link .badge-soon {
    font-size: 10px;
    padding: 1px 6px;
    border-radius: var(--radius-sm);
    background: var(--surface-alt);
    color: var(--text-muted);
    margin-left: auto;
}

.console-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    margin-left: 240px;
}

@media (max-width: 991.98px) {
    .console-main {
        margin-left: 0;
    }
}

/* Bottom-of-sidebar mirror of the topbar action icons (dashboard/admin/api,
   profile/theme/logout). Hidden by default — the topbar keeps showing them
   from the sm breakpoint up; only xs viewers see them here instead, since
   there isn't enough width in the topbar to keep them all visible. */
.console-sidebar-bottom {
    display: none;
}

.console-sidebar-bottom form {
    margin: 0;
}

.console-sidebar-bottom .console-nav-link {
    width: 100%;
    background: none;
    border: 0;
    text-align: left;
}

@media (max-width: 575.98px) {
    .console-topbar-actions {
        display: none !important;
    }

    .console-sidebar-bottom {
        display: block;
        margin-top: auto;
        padding-top: var(--space-sm);
        border-top: 1px solid var(--border);
    }
}

.console-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    padding: var(--space-sm) var(--space-lg);
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.console-content {
    padding: var(--space-lg);
    max-width: 1200px;
}

/* ---------------------------------------------------------------------- */
/* Shared content components                                              */
/* ---------------------------------------------------------------------- */
.console-card {
    background: var(--surface);
    border: 1px solid var(--border);
}

.console-tabs .nav-link {
    color: var(--text-muted);
}

.console-tabs .nav-link.active {
    color: var(--color-primary);
    border-color: var(--border) var(--border) var(--surface);
}

.console-shell .card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    margin-bottom: var(--space-md);
    box-shadow: 0 1px 2px rgba(0, 0, 0, .15);
}

.console-shell .table {
    font-size: 14px;
}

.console-shell .table th {
    background: var(--surface-alt);
    font-weight: 600;
}

.console-shell form p {
    margin-bottom: var(--space-md);
}

.console-shell .muted {
    color: var(--text-muted);
    font-size: 13px;
}

.console-shell pre {
    background: var(--surface-alt);
    padding: var(--space-sm);
    border-radius: var(--radius-sm);
    overflow-x: auto;
    max-width: 420px;
    font-size: 12px;
}

.console-shell .message-list {
    list-style: none;
    padding: 0;
}

.console-shell .message-error {
    border-left: 4px solid var(--error);
}

.console-shell .message-success {
    border-left: 4px solid var(--success);
}

.console-shell .severity-info {
    color: var(--severity-info);
}

.console-shell .severity-warning {
    color: var(--severity-warning);
}

.console-shell .severity-critical {
    color: var(--severity-critical);
    font-weight: bold;
}

.console-shell .lucide {
    width: 1em;
    height: 1em;
    vertical-align: -0.125em;
}

.console-shell .theme-toggle .icon-sun,
.console-shell .theme-toggle .icon-moon {
    display: none;
}

html[data-bs-theme="light"] .console-shell .theme-toggle .icon-sun {
    display: inline;
}

html[data-bs-theme="dark"] .console-shell .theme-toggle .icon-moon {
    display: inline;
}

.console-shell .client-select {
    max-width: 160px;
}

/* ---------------------------------------------------------------------- */
/* Tables: consistent column rhythm across every list/detail page.        */
/* The actions column is always icon-only buttons, right-aligned, and     */
/* sized to content (width: 1%) so it stops stretching unpredictably wide */
/* depending on how long a text label happens to be per page.             */
/* ---------------------------------------------------------------------- */
.console-table th,
.console-table td {
    vertical-align: middle;
}

.console-table .col-actions {
    width: 1%;
    white-space: nowrap;
    text-align: right;
}

.console-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    line-height: 1;
}

.console-action-btn + .console-action-btn,
.console-inline-edit-trigger + .console-action-btn {
    margin-left: 4px;
}
