/* ============================================================================
   split-panels.css — Unified chrome for all right-side component split panels
   (canvas, knowledge graph, scheduler, dashboard, flow).

   One source of truth for header layout, action buttons, the instance-switcher
   button, and the switcher dropdown menu. Every panel <aside> carries a
   `--sp-accent` custom property (its component manifest icon_accent); the shared
   rules drive icon colour, switcher hover, and active states from that single
   variable, so every panel gets identical treatment with a per-component hue.

   THEME-AWARE: all colours come from CSS variables (themes.css, dark + light).
   Accent tints are derived from --sp-accent via color-mix. Icons are monochrome.
   ============================================================================ */

/* Panel root — each <aside> overrides --sp-accent inline. */
.sp-panel { --sp-accent: var(--teradata-orange, #F15F22); }

/* ── Header bar (identical for every panel) ──────────────────────────────── */
.sp-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 9px 12px;
    min-height: 46px;
    flex-shrink: 0;
    /* Calm elevated toolbar surface (slate-800), lighter than the heavy slate-900
       overlay — reads as a refined header, not a dark navy band. */
    background: var(--bg-secondary, rgba(31, 33, 38, 0.92));
    border-bottom: 1px solid var(--border-secondary, rgba(148, 163, 184, 0.1));
    /* Top inner-light highlight — turns a flat panel into a crafted surface */
    box-shadow: inset 0 1px 0 var(--glass-border, rgba(255, 255, 255, 0.05));
}
.sp-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex: 1;
}

/* Accent identity icon — colour comes only from --sp-accent */
.sp-accent-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--sp-accent);
    flex-shrink: 0;
}
.sp-accent-icon svg { width: 16px; height: 16px; }

/* Static title (panels without a switcher, e.g. scheduler) */
.sp-title {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-primary, #f8fafc);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

/* Instance-selector — a quiet title-dropdown, not a boxed button */
.sp-switcher {
    display: flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: 1px solid transparent;
    border-radius: var(--radius-md, 8px);
    padding: 4px 8px 4px 6px;
    color: var(--text-primary, #f8fafc);
    font: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    cursor: pointer;
    max-width: 240px;
    min-width: 0;
    transition: background var(--duration-fast, 0.2s) var(--ease-out-expo, ease),
                color var(--duration-fast, 0.2s) var(--ease-out-expo, ease);
}
.sp-switcher:hover {
    background: var(--hover-bg, rgba(148, 163, 184, 0.08));
}
.sp-switcher:hover > svg { color: var(--sp-accent); }
.sp-switcher-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}
.sp-switcher > svg { width: 11px; height: 11px; flex-shrink: 0; color: var(--text-muted); transition: color var(--duration-fast, 0.2s) ease; }

/* ── Right-side action buttons — borderless "ghost" icons ─────────────────── */
.sp-header-actions {
    display: flex;
    align-items: center;
    gap: 1px;
    flex-shrink: 0;
}
/* Ghost button: no resting box. A soft pill reveals only on hover, so a row of
   icons reads as a clean cluster instead of a strip of little containers. */
.sp-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: var(--radius-md, 8px);
    border: none;
    background: none;
    color: var(--text-muted, #94a3b8);
    cursor: pointer;
    transition: color var(--duration-fast, 0.15s) ease,
                background var(--duration-fast, 0.15s) ease,
                transform var(--duration-instant, 0.1s) ease;
    flex-shrink: 0;
}
.sp-action-btn:hover {
    color: var(--text-primary, #f8fafc);
    background: var(--hover-bg, rgba(148, 163, 184, 0.08));
}
.sp-action-btn:active { transform: scale(0.92); }
.sp-action-btn svg { width: 15px; height: 15px; }

/* Active state = panel accent (e.g. fullscreen toggled on) — tint, no hard box */
.sp-action-btn.is-active {
    color: var(--sp-accent);
    background: color-mix(in srgb, var(--sp-accent) 12%, transparent);
}
/* "Mode" states are deliberately distinct from identity accent.
   edit-active = purple (dashboard edit mode); active = green (refresh running). */
.sp-action-btn.edit-active {
    color: #c084fc;
    background: rgba(147, 51, 234, 0.14);
}
.sp-action-btn.active {
    color: #4ade80;
    background: rgba(74, 222, 128, 0.12);
}

/* Faded hairline — groups actions without a hard rule. Real separation is
   carried by the whitespace either side. */
.sp-divider {
    width: 1px;
    height: 18px;
    background: linear-gradient(to bottom,
        transparent,
        var(--border-primary, rgba(148, 163, 184, 0.18)) 25%,
        var(--border-primary, rgba(148, 163, 184, 0.18)) 75%,
        transparent);
    margin: 0 6px;
    flex-shrink: 0;
}

/* ── Secondary toolbar row (canvas editor controls live here) ────────────── */
.sp-subtoolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    flex-shrink: 0;
    flex-wrap: wrap;
    /* One cohesive header surface — same fill as .sp-header; rows separated by the
       title bar's hairline, not a colour block. */
    background: var(--bg-secondary, rgba(31, 33, 38, 0.92));
    border-bottom: 1px solid var(--border-secondary, rgba(148, 163, 184, 0.1));
}

/* ── Shared switcher dropdown menu (portal, position:fixed) ──────────────── */
.sp-switcher-menu {
    position: fixed;
    min-width: 240px;
    max-width: 360px;
    background: var(--bg-overlay, rgba(20, 22, 25, 0.98));
    border: 1px solid var(--border-primary, rgba(148, 163, 184, 0.18));
    border-radius: 10px;
    box-shadow: var(--shadow-xl, 0 20px 40px rgba(0, 0, 0, 0.5));
    z-index: 1000;
    overflow: hidden auto;
    max-height: 60vh;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    animation: sp-menu-in 0.16s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes sp-menu-in {
    from { opacity: 0; transform: translateY(-8px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
.sp-switcher-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 14px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-secondary, rgba(148, 163, 184, 0.1));
    transition: background 0.15s;
}
.sp-switcher-item:last-child { border-bottom: none; }
.sp-switcher-item:hover { background: var(--hover-bg, rgba(148, 163, 184, 0.08)); }
.sp-switcher-item.is-current { background: color-mix(in srgb, var(--sp-accent) 12%, transparent); }
.sp-switcher-item-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    flex-shrink: 0;
}
.sp-switcher-item.is-current .sp-switcher-item-dot { background: var(--sp-accent); }
.sp-switcher-item-name {
    flex: 1;
    min-width: 0;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.sp-switcher-item-meta { font-size: 0.72rem; color: var(--text-muted); flex-shrink: 0; }
.sp-switcher-new {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 14px;
    cursor: pointer;
    color: var(--sp-accent);
    font-size: 0.82rem;
    font-weight: 500;
    border-top: 1px solid var(--border-primary, rgba(148, 163, 184, 0.18));
    transition: background 0.15s;
}
.sp-switcher-new:hover { background: color-mix(in srgb, var(--sp-accent) 12%, transparent); }
.sp-switcher-new svg { width: 14px; height: 14px; flex-shrink: 0; }
.sp-switcher-empty { padding: 10px 14px; font-size: 0.8rem; color: var(--text-muted); }

/* ── Auto-hiding sub-toolbar ──────────────────────────────────────────────────
   Components with a secondary toolbar (KG search/filter, flow Layout/Options,
   canvas editor controls) collapse it by default to keep the canvas clean.
   Hovering the panel header reveals it; the pin button in the header locks it
   open (state persisted per panel by subHeaderAutohide.js). The collapse is
   driven purely by classes on the .sp-panel, so it works for plain-DOM (KG,
   canvas) and React (flow) toolbars alike. The height var (--sp-subheader-h) is
   measured by the helper so the slide uses the toolbar's true height. */
[data-sp-subheader] {
    /* border-box so max-height:0 collapses padding + border with it (no residual
       strip), while scrollHeight still measures the toolbar's true height. */
    box-sizing: border-box;
    overflow: hidden;
    transition: max-height 0.26s var(--ease-out-expo, cubic-bezier(0.16,1,0.3,1)),
                opacity 0.18s ease;
}
.sp-panel.sp-has-subheader:not(.sp-subheader-open):not(.sp-subheader-pinned) [data-sp-subheader] {
    max-height: 0;
    opacity: 0;
    pointer-events: none;
}
.sp-panel.sp-subheader-open   [data-sp-subheader],
.sp-panel.sp-subheader-pinned [data-sp-subheader] {
    max-height: var(--sp-subheader-h, 240px);
    opacity: 1;
}
/* Pin toggle — injected as the first .sp-header-actions button by the helper. */
.sp-subheader-pin svg { width: 15px; height: 15px; }
.sp-panel.sp-subheader-pinned .sp-subheader-pin {
    color: var(--sp-accent);
    background: color-mix(in srgb, var(--sp-accent) 14%, transparent);
}
