/* ========================================
   CONSOLE (staff console frame)
   ========================================
   The operator console (its own host, OperatorConsoleLayout.cs) wears the web app's shell: .ada-topbar,
   .ada-sidebar, .ada-nav-link, .ada-main. What a staff console adds is here: a sidebar
   section whose pages open in a flyout, and the sheet the page bodies sit on.

   The page bodies are still C# strings with their own <style> blocks (AGENCY-727 phase 2
   moves them onto components). Until then .ada-console-body keeps them as they were
   written: light, 13px, and with the browser's own margins and padding, which ada.css's
   reset would otherwise take away. Remove each rule here as the last body that needs it
   moves. */

/* A section (CRM, Support, Ops...): its trigger is a nav link, its pages a flyout beside
   the sidebar. console.js opens it on hover, focus or a tap and sets --ada-flyout-top
   to the trigger's top, because the sidebar's nav scrolls and would clip a flyout inside it. */
.ada-console-nav-group { position: relative; }

.ada-console-nav-trigger {
    width: 100%;
    border: none;
    background: none;
    font: inherit;
    text-align: start;
    cursor: pointer;
}

.ada-console-nav-trigger.ada-active { color: var(--text-primary); }
.ada-console-nav-trigger.ada-active i { opacity: 1; }

.ada-console-nav-chevron { font-size: 10px; opacity: 0.5; }

.ada-console-flyout {
    display: none;
    position: fixed;
    top: var(--ada-flyout-top, var(--topbar-height));
    left: calc(var(--sidebar-width) - 8px);
    min-width: 200px;
    padding: 6px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    z-index: 950;
}

/* A bridge across the gap, so the pointer can travel from the trigger to the flyout. */
.ada-console-flyout::before {
    content: '';
    position: absolute;
    right: 100%;
    top: 0;
    width: 24px;
    height: 100%;
}

.ada-console-nav-group.ada-open > .ada-console-flyout { display: block; }

.ada-console-flyout-title {
    padding: 6px 10px 8px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-tertiary);
}

.ada-console-flyout-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 10px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 14px;
    white-space: nowrap;
    text-decoration: none;
}

.ada-console-flyout-link i { width: 16px; font-size: 13px; text-align: center; opacity: 0.7; }

.ada-console-flyout-link:hover,
.ada-console-flyout-link:focus-visible {
    color: var(--text-primary);
    background: var(--bg-hover);
    text-decoration: none;
}

.ada-console-flyout-link.ada-active {
    color: var(--accent);
    background: var(--accent-subtle);
}

.ada-console-flyout-link.ada-active i { opacity: 1; }

/* The top bar's actions are buttons as well as links. */
button.ada-topbar-create { border: none; font-family: inherit; cursor: pointer; }

/* The staff-console marker (OperatorConsoleLayout.StaffConsoleMarker): the operator console changes real
   customers' data, so it says so. A strip of the environment's colour runs along the top bar, and
   a "Staff console" badge with the environment sits beside the logo and in the phone drawer. */
.ada-console-env--production { --console-env: var(--palette-amber-500); }
.ada-console-env--development { --console-env: var(--palette-purple-500); }
.ada-console-env--test { --console-env: var(--tone-cyan-fg); }

.ada-operator-console .ada-topbar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--console-env);
}

.ada-console-marker {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: 8px;
    white-space: nowrap;
}

.ada-console-marker .ada-badge i { margin-right: 2px; }

/* The drawer's header (a phone) has the marker on the left and its close button on the right. */
.ada-operator-console .ada-sidebar-drawer-header { justify-content: space-between; }
.ada-sidebar-drawer-header .ada-console-marker { margin-left: 0; }

@media (max-width: 767px) {
    /* The top bar keeps "Staff console"; the environment is in the drawer. */
    .ada-topbar .ada-console-marker-env { display: none; }
    .ada-topbar .ada-console-marker { margin-left: 4px; }
}

/* A record's facts as label and value (a ticket's details): labels in a column beside their
   values, and above them on a phone, where a long email or note would run off a table. */
.ada-console-facts {
    display: grid;
    grid-template-columns: minmax(140px, max-content) minmax(0, 1fr);
    gap: 12px 24px;
    margin: 0;
    padding: 16px 20px;
}

.ada-console-facts dt {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-tertiary);
}

.ada-console-facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

@media (max-width: 767px) {
    .ada-console-facts { grid-template-columns: minmax(0, 1fr); gap: 2px; }
    .ada-console-facts dd { margin-bottom: 12px; }
}

/* Before the console (sign-in, a refusal): the strip along the top of the page, and the marker
   centred under the logo. */
.ada-auth-page.ada-operator-console::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--console-env);
}

.ada-auth-container > .ada-console-marker {
    display: flex;
    justify-content: center;
    margin: -32px 0 32px;
}

/* A stack trace on the operator console's error page: monospaced, kept as written, scrolling sideways. */
.ada-console-trace {
    margin-top: 8px;
    padding: 12px 16px;
    max-height: 480px;
    overflow: auto;
    background: var(--bg-subtle);
    border-radius: var(--radius-md);
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 1.5;
    white-space: pre;
}

/* Text shown as written (an article's Markdown): line breaks kept, long lines wrapped, and a long
   text scrolls inside its card. */
.ada-console-source {
    margin: 0;
    padding: 16px 20px;
    max-height: 500px;
    overflow: auto;
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.6;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

/* A generated video on its job's page (Video jobs): as wide as its card, up to 640px, never
   its own (often 1920px) width. */
.ada-console-video {
    display: block;
    width: 100%;
    max-width: 640px;
    border-radius: var(--radius-md);
    background: var(--bg-subtle);
}

/* The sheet the page body sits on. */
.ada-console-body {
    margin: 0 24px 24px 0;
    padding: 20px 24px;
    max-width: 1800px;
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-sm);
    color: var(--text-primary);
    /* The sheet is light in either theme (data-theme='light'), so are its native controls. */
    color-scheme: light;
    font-size: 13px;
    line-height: 1.4;
    /* A body wider than the screen (a wide table) scrolls inside the sheet rather than being
       cut off at the page's edge. */
    overflow-x: auto;
}

/* Phase 1 only: undo ada.css's `* { margin: 0; padding: 0 }` inside a body, and the element
   styles the old layout gave every page. :where() keeps them at the lowest specificity, so a
   body's own <style> still wins as it did. */
:where(.ada-console-body) * { margin: revert; padding: revert; }
/* A cell's 1px is the browser's presentational hint, not its stylesheet, so revert drops it. */
:where(.ada-console-body) :where(td, th) { padding: 1px; }
:where(.ada-console-body) h1 { margin-top: 0; font-size: 22px; font-weight: 600; }
:where(.ada-console-body) h2 { font-size: 18px; font-weight: 600; }
:where(.ada-console-body) h3 { font-size: 15px; font-weight: 600; }
:where(.ada-console-body) table { border-collapse: collapse; }
:where(.ada-console-body) th { text-align: left; font-weight: 600; }

@media (max-width: 767px) {
    .ada-console-body {
        margin: 0;
        padding: 16px;
        border: none;
        border-radius: 0;
        box-shadow: none;
    }

    /* In the drawer a section opens in place, under its trigger. */
    .ada-console-flyout {
        position: static;
        min-width: 0;
        margin: 2px 0 6px 20px;
        padding: 0;
        background: none;
        border: none;
        box-shadow: none;
    }

    .ada-console-flyout::before,
    .ada-console-flyout-title { display: none; }

    .ada-console-nav-group.ada-open .ada-console-nav-chevron { transform: rotate(90deg); }
}

/* With labels hidden (a collapsed sidebar) the chevron goes with them. */
@media (min-width: 768px) and (max-width: 1279px) {
    body:not(.ada-sidebar-pref-expanded) .ada-console-nav-chevron { display: none; }
}

@media (min-width: 1280px) {
    body.ada-sidebar-pref-collapsed .ada-console-nav-chevron { display: none; }
}
