/* ============================================
   Tekvwa Analysis - Excel/SPSS Style Navigation
   Modern Ribbon Interface

   Strictly black & white per the app's design constraint — no accent color anywhere in this
   file (the previous version used a Windows-blue #0078d4 accent for hover/active/links; every
   occurrence below is now a shade of black/gray instead). Chrome that sits directly against the
   themeable content area (ribbon tabs/panel, status bar, dataset bar, dropdown menus) uses the
   CSS custom properties defined in base.html so it inverts correctly with the dark-mode toggle.
   The menu bar itself keeps its own fixed dark background by design (a permanent title bar, like
   a desktop app's, rather than something that should flip white in light mode) — only its color
   values were de-blued, not converted to the theme variables.
   ============================================ */

/* Sticky wrapper around the menu bar + ribbon tabs + ribbon panel, so the whole nav
   (including the File menu's Dashboards link and every ribbon-tab button) stays reachable
   while the page content scrolls, instead of scrolling away with it. */
.app-header {
    position: sticky;
    top: 0;
    z-index: 1000;
}

/* Menu Bar - Top Level (File, Data, Analyze, etc.) — a fixed deep-evergreen title bar (the
   Tekvwa brand colour, --brand #1f4e3d family). Intentionally NOT theme-reactive: it stays the
   same dark green in light and dark mode so the product reads consistently. */
.menu-bar {
    background: #163a2d;
    border-bottom: 1px solid #2f5d4e;
    padding: 0;
    margin: 0;
    display: flex;
    align-items: center;
    height: 32px;
    position: relative;
    z-index: 1000;
}

.menu-bar .brand-section {
    display: flex;
    align-items: center;
    padding: 0 14px;
    height: 100%;
    background: #0f2f24;
    color: #ffffff;
    font-weight: 600;
    font-size: 13px;
    letter-spacing: 0.3px;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s ease;
}

.menu-bar .brand-section:hover,
.menu-bar .brand-section.active {
    background: #0a241b;
}

.menu-bar .brand-section .brand-caret {
    margin-left: 8px;
    font-size: 10px;
    opacity: 0.7;
}

.menu-bar .brand-section i {
    margin-right: 8px;
    font-size: 14px;
}

.menu-bar .brand-section .brand-logo {
    height: 20px;
    width: auto;
    margin-right: 8px;
}

.menu-bar .menu-items {
    display: flex;
    align-items: center;
    height: 100%;
    flex: 1;
    padding-left: 8px;
}

.menu-bar .menu-item {
    color: #e0e0e0;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    border-radius: 3px;
    margin: 0 1px;
    position: relative;
    text-decoration: none;
    display: flex;
    align-items: center;
    height: 26px;
}

.menu-bar .menu-item:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}

.menu-bar .menu-item.active {
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
}

.menu-bar .menu-item i {
    margin-right: 6px;
    font-size: 12px;
    opacity: 0.85;
}

.menu-bar .menu-right {
    display: flex;
    align-items: center;
    padding-right: 12px;
    gap: 8px;
}

.menu-bar .user-info {
    color: #aaa;
    font-size: 12px;
    padding: 4px 10px;
    background: rgba(255,255,255,0.08);
    border-radius: 3px;
}

.menu-bar .user-info i {
    margin-right: 6px;
}

/* Ribbon Tabs */
.ribbon-tabs {
    background: var(--off-white);
    border-bottom: 1px solid var(--border-gray);
    padding: 0;
    display: flex;
    align-items: flex-end;
    height: 36px;
}

.ribbon-tab {
    padding: 8px 20px;
    font-size: 12px;
    font-weight: 600;
    color: var(--medium-gray);
    cursor: pointer;
    border: 1px solid transparent;
    border-bottom: none;
    margin: 0 2px;
    margin-bottom: -1px;
    border-radius: 4px 4px 0 0;
    transition: all 0.15s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ribbon-tab:hover {
    background: var(--hover-gray);
    color: var(--primary-black);
}

.ribbon-tab.active {
    background: var(--background-white);
    border-color: var(--border-gray);
    border-top: 2px solid var(--brand);
    color: var(--brand);
    position: relative;
}

.ribbon-tab.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--background-white);
}

/* Ribbon Content Panel */
.ribbon-panel {
    background: var(--background-white);
    border-bottom: 2px solid var(--border-gray);
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 24px;
    min-height: 80px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.ribbon-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 4px 16px;
    border-right: 1px solid var(--border-gray);
    min-width: 80px;
}

.ribbon-group:last-child {
    border-right: none;
}

.ribbon-group-label {
    font-size: 10px;
    color: var(--medium-gray);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 4px;
    font-weight: 600;
}

.ribbon-group-buttons {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 4px;
}

.ribbon-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 6px 12px;
    border: none;
    background: transparent;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
    color: var(--dark-gray);
    min-width: 56px;
}

.ribbon-btn:hover {
    background: var(--hover-gray);
    color: var(--primary-black);
}

.ribbon-btn.large {
    padding: 8px 16px;
    min-width: 70px;
}

.ribbon-btn i {
    font-size: 20px;
    margin-bottom: 4px;
}

.ribbon-btn.large i {
    font-size: 24px;
    margin-bottom: 6px;
}

.ribbon-btn span {
    font-size: 11px;
    font-weight: 500;
    text-align: center;
    line-height: 1.2;
}

.ribbon-btn.disabled {
    opacity: 0.4;
    pointer-events: none;
}

/* Status Bar at Bottom — positioning (fixed/bottom/z-index) now lives on the .app-footer
   wrapper in base.html, which pins this together with the site footer right below it as one
   unit; this stays a plain-flow child of that wrapper. */
.status-bar {
    background: var(--off-white);
    border-top: 1px solid var(--border-gray);
    padding: 4px 16px;
    font-size: 12px;
    color: var(--dark-gray);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.status-bar .status-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.status-bar .status-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.status-bar .status-item i {
    color: var(--primary-black);
}

/* Status indicator dot: kept semantic (success/warning/error) rather than forced grayscale —
   the one deliberate exception to "black & white only," since red/green/yellow here communicate
   state, not brand decoration -- they now route through the --status-* tokens (base.html /
   docs/DESIGN_SYSTEM.md), so the status palette has a single source of truth. */
.status-bar .status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--status-good);
}

.status-bar .status-indicator.warning {
    background: var(--status-warning);
}

.status-bar .status-indicator.error {
    background: var(--status-critical);
}

/* Dataset Info Bar */
.dataset-bar {
    background: var(--off-white);
    border-bottom: 1px solid var(--border-gray);
    padding: 6px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
}

.dataset-bar .dataset-info {
    display: flex;
    align-items: center;
    gap: 20px;
    color: var(--primary-black);
    font-weight: 500;
}

.dataset-bar .dataset-info i {
    margin-right: 6px;
}

.dataset-bar .dataset-actions {
    display: flex;
    gap: 8px;
}

.dataset-bar .dataset-actions .btn-sm {
    font-size: 11px;
    padding: 3px 10px;
}

/* "You're in the classic view — open the Workbench" tip (Track I: route-to-workbench) */
.classic-view-hint {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    font-size: 12px;
    color: var(--brand-contrast, #fff);
    background: var(--brand, #1f4e3d);
    border-bottom: 1px solid var(--brand-strong, #163a2d);
}

.classic-view-hint .cvh-msg {
    flex: 1 1 auto;
    line-height: 1.35;
}

.classic-view-hint .cvh-msg i {
    margin-right: 6px;
}

.classic-view-hint .btn {
    flex: 0 0 auto;
    font-size: 11px;
    padding: 3px 12px;
    background: #fff;
    border-color: #fff;
    color: var(--brand, #1f4e3d);
    font-weight: 600;
}

.classic-view-hint .cvh-dismiss {
    flex: 0 0 auto;
    background: transparent;
    border: 0;
    color: var(--brand-contrast, #fff);
    font-size: 18px;
    line-height: 1;
    padding: 0 4px;
    cursor: pointer;
    opacity: 0.8;
}

.classic-view-hint .cvh-dismiss:hover {
    opacity: 1;
}

/* Pitch P4 — "confirm your email" bar. Amber (informational, not an error). */
.verify-email-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    font-size: 12px;
    color: var(--status-warning-text, #856404);
    background: var(--status-warning-bg, #fff3cd);
    border-bottom: 1px solid var(--status-warning, #fab219);
}

.verify-email-bar > span {
    flex: 1 1 auto;
    line-height: 1.35;
}

.verify-email-bar > span i {
    margin-right: 6px;
}

.verify-email-bar .btn {
    flex: 0 0 auto;
    font-size: 11px;
    padding: 3px 12px;
    font-weight: 600;
}

.verify-email-bar .veb-dismiss {
    flex: 0 0 auto;
    background: transparent;
    border: 0;
    color: var(--status-warning-text, #856404);
    font-size: 18px;
    line-height: 1;
    padding: 0 4px;
    cursor: pointer;
    opacity: 0.8;
}

.verify-email-bar .veb-dismiss:hover {
    opacity: 1;
}

/* Pitch P3 — GA4 consent banner. Neutral brand wash, not the warning palette: this is a routine
   choice, not a problem to fix, so it shouldn't read as one. */
.analytics-consent-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    font-size: 12px;
    color: var(--brand-strong);
    background: var(--brand-tint);
    border-bottom: 1px solid var(--brand-border);
}

.analytics-consent-bar > span {
    flex: 1 1 auto;
    line-height: 1.35;
}

.analytics-consent-bar > span i {
    margin-right: 6px;
}

.analytics-consent-bar .btn {
    flex: 0 0 auto;
    font-size: 11px;
    padding: 3px 12px;
    font-weight: 600;
}

/* Quick Access Toolbar */
.quick-access {
    background: var(--off-white);
    padding: 2px 8px;
    display: flex;
    align-items: center;
    gap: 2px;
    border-bottom: 1px solid var(--border-gray);
}

.quick-access .qa-btn {
    padding: 4px 8px;
    border: none;
    background: transparent;
    color: var(--dark-gray);
    border-radius: 3px;
    cursor: pointer;
    font-size: 14px;
}

.quick-access .qa-btn:hover {
    background: var(--hover-gray);
    color: var(--primary-black);
}

.quick-access .qa-separator {
    width: 1px;
    height: 16px;
    background: var(--border-gray);
    margin: 0 4px;
}

/* Dropdown Menus - Excel Style */
.excel-dropdown {
    position: fixed;
    background: var(--background-white);
    border: 1px solid var(--border-gray);
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    min-width: 240px;
    z-index: 9999;
    display: none;
    border-radius: 0 0 4px 4px;
}

.excel-dropdown.show {
    display: block;
}

.excel-dropdown .dropdown-section {
    padding: 6px 0;
    border-bottom: 1px solid var(--border-gray);
}

.excel-dropdown .dropdown-section:last-child {
    border-bottom: none;
}

.excel-dropdown .dropdown-header {
    padding: 6px 16px;
    font-size: 11px;
    font-weight: 600;
    color: var(--medium-gray);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.excel-dropdown .dropdown-item {
    display: flex;
    align-items: center;
    padding: 8px 16px;
    color: var(--primary-black);
    text-decoration: none;
    font-size: 13px;
    transition: all 0.1s ease;
    cursor: pointer;
}

.excel-dropdown .dropdown-item:hover {
    background: var(--brand);
    color: var(--brand-contrast, #fff);
}

.excel-dropdown .dropdown-item:hover i {
    color: var(--background-white);
}

.excel-dropdown .dropdown-item.disabled,
.excel-dropdown .dropdown-item.disabled:hover {
    opacity: 0.5;
    pointer-events: none;
    background: transparent;
    color: var(--medium-gray);
    cursor: not-allowed;
}

.excel-dropdown .dropdown-item i {
    width: 20px;
    margin-right: 10px;
    font-size: 14px;
    text-align: center;
    color: var(--medium-gray);
}

.excel-dropdown .dropdown-item .shortcut {
    margin-left: auto;
    font-size: 11px;
    color: var(--medium-gray);
}

/* A static mid-gray rather than a themed variable on purpose: the parent item's background
   flips between black (light mode) and white (dark mode) on hover, and this needs to stay
   readable against both without inverting itself. */
.excel-dropdown .dropdown-item:hover .shortcut {
    color: #999999;
}

/* Track I8 — the Format menu (cell styling for the Data grid) */
.format-dropdown {
    min-width: 268px;
}

.format-dropdown .dropdown-section:first-child {
    padding: 10px 16px;
}

.format-dropdown .fmt-hint {
    font-size: 11px;
    color: var(--medium-gray);
    margin-bottom: 8px;
    line-height: 1.35;
}

.format-dropdown .fmt-hint.is-armed {
    color: var(--brand, #1f4e3d);
    font-weight: 600;
}

.format-dropdown .fmt-row {
    display: flex;
    gap: 6px;
    margin-bottom: 8px;
}

.format-dropdown .fmt-btn {
    flex: 1 1 auto;
    padding: 5px 0;
    border: 1px solid var(--border-gray);
    background: var(--background-white);
    color: var(--primary-black);
    border-radius: 3px;
    font-size: 13px;
    cursor: pointer;
}

.format-dropdown .fmt-btn:hover {
    border-color: var(--brand, #1f4e3d);
}

.format-dropdown .fmt-btn.is-active {
    background: var(--brand, #1f4e3d);
    color: var(--brand-contrast, #fff);
    border-color: var(--brand, #1f4e3d);
}

.format-dropdown .fmt-field {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 7px;
    font-size: 12px;
    color: var(--primary-black);
}

.format-dropdown .fmt-select {
    flex: 0 0 150px;
    padding: 3px 6px;
    border: 1px solid var(--border-gray);
    border-radius: 3px;
    background: var(--background-white);
    color: var(--primary-black);
    font-size: 12px;
}

.format-dropdown.is-disabled {
    opacity: 0.55;
    pointer-events: none;
}

/* Track I8 — the visible formatting toolbar in the Home ribbon (Excel's font group). */
.ribbon-group-format {
    min-width: 0;
}

.fmt-toolbar {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 4px;
    flex-wrap: wrap;
}

.fmt-toolbar.is-disabled {
    opacity: 0.5;
    pointer-events: none;
}

/* Track M1 — the on-grid formatting strip (a second .fmt-toolbar instance sitting directly
   above the data grid, so the controls are visible without opening the Home ribbon). */
.fmt-toolbar-strip {
    margin-bottom: 0;
    border-top: 1px solid var(--border-gray);
    border-bottom: 1px solid var(--border-gray);
    background: var(--brand-tint, #eef4f1);
}

.fmt-toolbar .fmt-select {
    height: 26px;
    padding: 2px 4px;
    border: 1px solid var(--border-gray);
    border-radius: 3px;
    background: var(--background-white);
    color: var(--primary-black);
    font-size: 12px;
    max-width: 130px;
}

.fmt-toolbar .fmt-select-sm {
    max-width: 62px;
}

.fmt-toolbar .fmt-btn {
    min-width: 28px;
    height: 26px;
    padding: 0 6px;
    border: 1px solid var(--border-gray);
    background: var(--background-white);
    color: var(--primary-black);
    border-radius: 3px;
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
}

.fmt-toolbar .fmt-btn:hover {
    border-color: var(--brand, #1f4e3d);
}

.fmt-toolbar .fmt-btn.is-active {
    background: var(--brand, #1f4e3d);
    color: var(--brand-contrast, #fff);
    border-color: var(--brand, #1f4e3d);
}

.fmt-toolbar .fmt-btn-wide {
    color: var(--medium-gray);
}

.fmt-toolbar .fmt-sep {
    width: 1px;
    height: 20px;
    background: var(--border-gray);
    margin: 0 2px;
}

.ribbon-group-format .fmt-hint-inline {
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    color: var(--medium-gray);
}

.ribbon-group-format .fmt-hint-inline.is-armed {
    color: var(--brand, #1f4e3d);
    font-weight: 600;
}

.excel-dropdown .dropdown-divider {
    height: 1px;
    background: var(--border-gray);
    margin: 4px 0;
}

/* ============================================================================
   Excel-style swatch colour picker (static/js/cell_format_color.js)
   Replaces the browser-native <input type=color> on the Format controls.
   ============================================================================ */
.fmt-colorpick {
    position: relative;
    display: inline-block;
}

.fmt-colorpick-trigger {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    height: 26px;
    padding: 0 5px;
    border: 1px solid var(--border-gray);
    border-radius: 3px;
    background: var(--background-white);
    color: var(--medium-gray);
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
}

.fmt-colorpick-trigger:hover {
    border-color: var(--brand, #1f4e3d);
}

.fmt-colorpick.is-open .fmt-colorpick-trigger {
    border-color: var(--brand, #1f4e3d);
    box-shadow: 0 0 0 2px var(--brand-tint, #eef4f1);
}

/* The colour swatch shown in the trigger — the current text / fill colour. */
.fmt-colorpick-bar {
    display: block;
    width: 16px;
    height: 14px;
    border: 1px solid var(--border-gray);
    border-radius: 2px;
}

.fmt-colorpick-bar.is-none {
    background:
        linear-gradient(45deg, transparent 44%, #d0342c 44%, #d0342c 56%, transparent 56%),
        var(--background-white);
}

.fmt-colorpick-caret {
    font-size: 9px;
    opacity: 0.6;
}

.fmt-colorpick-menu {
    position: absolute;
    z-index: 1200;
    top: calc(100% + 4px);
    left: 0;
    padding: 8px;
    background: var(--background-white);
    border: 1px solid var(--border-gray);
    border-radius: 5px;
    box-shadow: 0 6px 22px rgba(0, 0, 0, 0.16);
    width: max-content;
}

/* Anchor the pop-out to the right of its trigger wherever the trigger sits near a right
   edge — the wide ribbon toolbar, the on-grid strip, and the narrow Format dropdown menu. */
.fmt-toolbar-strip .fmt-colorpick-menu,
.ribbon-group-format .fmt-colorpick-menu,
.format-dropdown .fmt-colorpick-menu {
    left: auto;
    right: 0;
}

.fmt-colorpick-row {
    display: flex;
    gap: 3px;
}

.fmt-colorpick-matrix {
    margin-top: 4px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.fmt-colorpick-swatch {
    width: 18px;
    height: 18px;
    padding: 0;
    border: 1px solid rgba(0, 0, 0, 0.18);
    border-radius: 2px;
    cursor: pointer;
}

.fmt-colorpick-swatch:hover {
    outline: 2px solid var(--brand, #1f4e3d);
    outline-offset: 1px;
}

.fmt-colorpick-clear {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    margin-bottom: 6px;
    padding: 4px 6px;
    border: 1px solid var(--border-gray);
    border-radius: 3px;
    background: var(--background-white);
    color: var(--primary-black);
    font-size: 12px;
    cursor: pointer;
}

.fmt-colorpick-clear:hover {
    border-color: var(--brand, #1f4e3d);
}

.fmt-colorpick-clear-chip {
    width: 16px;
    height: 16px;
    border: 1px solid var(--border-gray);
    border-radius: 2px;
    background:
        linear-gradient(45deg, transparent 44%, #d0342c 44%, #d0342c 56%, transparent 56%),
        var(--background-white);
}

.fmt-colorpick-more {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border-gray);
    color: var(--primary-black);
    font-size: 12px;
    cursor: pointer;
}

.fmt-colorpick-more .fmt-colorpick-native {
    width: 24px;
    height: 20px;
    margin-left: auto;
    padding: 0;
    border: 1px solid var(--border-gray);
    border-radius: 3px;
    background: none;
    cursor: pointer;
}

/* Vertical Format-menu rows put the label first, the control right-aligned. */
.format-dropdown .fmt-field .fmt-colorpick {
    margin-left: auto;
}

/* Dark Mode Adjustments — only the always-dark menu bar needs manual tweaking now; every other
   rule above already inverts automatically via the CSS custom properties. */
[data-theme="dark"] .menu-bar {
    background: #0f2f24;
    border-bottom-color: #24483b;
}
