/* =========================================================================
   Expedient Brand Stylesheet — dark-first, with a light override.

   Sourced from the Expedient Brand Guide (updated 09/03/2021):
   - Primary colors: white, black, red (#F20505).
   - Secondary neutrals: #323232, #646464, #D2D2D2, #F0F0F0.
   - Typeface: Inter (Bold for headings, Regular for body).
   - Red for CTAs / accents; black or white for body depending on surface.

   Dark theme is the default. Users may flip to light via the nav toggle,
   which writes `data-theme="light"` on <html>. Tokens below are the only
   place where theme-specific colors live — components consume semantic
   variables so nothing is duplicated per theme.
   ========================================================================= */

:root {
    /* Brand constants (identical in both themes) */
    --brand-red:        #F20505;
    --brand-red-hover:  #ff2525;
    --brand-red-deep:   #B91C1C;

    /* ── DARK theme (default) ───────────────────────────────────────── */
    --bg-primary:     #000000;
    --bg-secondary:   #0A0A0A;
    --bg-card:        #141414;
    --bg-elevated:    #1A1A1A;
    --border:         #2A2A2A;
    --border-subtle:  #1F1F1F;
    --text-primary:   #FFFFFF;
    --text-secondary: #A3A3A3;
    --text-muted:     #737373;
    --chart-grid:     #262626;
    --chart-tick:     #A3A3A3;
    --surface-hover:  #1F1F1F;
    --focus-ring:     rgba(242, 5, 5, 0.35);

    --success: #22C55E;
    --warning: #F59E0B;

    --accent:       var(--brand-red);
    --accent-hover: var(--brand-red-hover);

    /* Layout */
    --nav-width: 220px;
    --nav-width-collapsed: 64px;

    /* Radii / shadows */
    --radius-sm: 6px;
    --radius:    8px;
    --radius-lg: 12px;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow:    0 2px 6px rgba(0, 0, 0, 0.5);
}

[data-theme="light"] {
    --bg-primary:     #FFFFFF;
    --bg-secondary:   #F8F8F8;
    --bg-card:        #FFFFFF;
    --bg-elevated:    #FFFFFF;
    --border:         #D2D2D2;
    --border-subtle:  #E5E5E5;
    --text-primary:   #000000;
    --text-secondary: #646464;
    --text-muted:     #9CA3AF;
    --chart-grid:     #E5E5E5;
    --chart-tick:     #646464;
    --surface-hover:  #F0F0F0;
    --focus-ring:     rgba(242, 5, 5, 0.18);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow:    0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { color-scheme: dark; }
[data-theme="light"] html,
html[data-theme="light"] { color-scheme: light; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background 0.2s ease, color 0.2s ease;
}

/* ── Layout ──────────────────────────────────────────────────────────── */

.app-layout {
    display: flex;
    min-height: 100vh;
}

.nav-rail {
    width: var(--nav-width);
    min-height: 100vh;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-subtle);
    padding: 1.5rem 1rem;
    position: fixed;
    top: 0;
    left: 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    z-index: 100;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.nav-brand {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem 1.25rem;
    margin-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-primary);
}

.expedient-logo-full,
.expedient-logo-icon {
    display: block;
    width: 100%;
    max-width: 170px;
    height: auto;
}

.expedient-logo-icon {
    max-width: 38px;
    display: none;
}

/* Wordmark glyphs inherit from currentColor (which = --text-primary) so the
   logo flips white/black with the theme. Red icon keeps its explicit
   #F20505 via .cls-1. The SVG mixes <path> and <polygon> elements — select
   every direct child so nothing slips through as default-black. */
.expedient-logo-full > *:not(.cls-1) {
    fill: currentColor;
}

.nav-app-name {
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    padding-left: 0.125rem;
    margin-top: 0.375rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.75rem;
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
}

.nav-link:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.nav-link.active {
    background: var(--brand-red);
    color: #FFFFFF;
}

.nav-link.active:hover {
    background: var(--brand-red-hover);
}

.nav-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.nav-spacer { flex: 1; }

.theme-toggle {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.theme-toggle:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
    border-color: var(--brand-red);
}

.theme-toggle-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* Swap which icon/label shows based on current theme. */
.theme-toggle .icon-sun,
.theme-toggle .label-light { display: none; }
.theme-toggle .icon-moon,
.theme-toggle .label-dark { display: inline-flex; }

[data-theme="light"] .theme-toggle .icon-moon,
[data-theme="light"] .theme-toggle .label-dark { display: none; }
[data-theme="light"] .theme-toggle .icon-sun,
[data-theme="light"] .theme-toggle .label-light { display: inline-flex; }

.main-content {
    margin-left: var(--nav-width);
    flex: 1;
    min-width: 0;
    padding: clamp(1rem, 2vw + 0.5rem, 2.5rem);
}

/* ── Responsive ──────────────────────────────────────────────────────── */

@media (max-width: 900px) {
    .nav-rail {
        width: var(--nav-width-collapsed);
        padding: 1rem 0.5rem;
    }
    .nav-app-name,
    .nav-link-label,
    .theme-toggle .theme-toggle-text {
        display: none;
    }
    .nav-brand {
        align-items: center;
        padding: 0.25rem 0 1rem;
    }
    .expedient-logo-full { display: none; }
    .expedient-logo-icon { display: block; }
    .nav-link { justify-content: center; padding: 0.625rem; }
    .theme-toggle {
        justify-content: center;
        padding: 0.5rem;
    }
    .main-content {
        margin-left: var(--nav-width-collapsed);
    }
}

/* ── Header ──────────────────────────────────────────────────────────── */

header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: clamp(1.5rem, 2.5vw, 2rem);
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--border);
}

h1 {
    font-size: clamp(1.5rem, 1.25rem + 1.25vw, 2.25rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.15;
    color: var(--text-primary);
}

h2 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--text-primary);
}

.page-eyebrow {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.5rem;
}

.status {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    flex-wrap: wrap;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    flex-shrink: 0;
}

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

/* ── Buttons ─────────────────────────────────────────────────────────── */

.btn {
    padding: 0.5rem 1rem;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.btn-primary {
    background: var(--brand-red);
    color: #FFFFFF;
    border-color: var(--brand-red);
}

.btn-primary:hover {
    background: var(--brand-red-hover);
    border-color: var(--brand-red-hover);
}

.btn-primary:disabled {
    background: var(--border);
    border-color: var(--border);
    color: var(--text-muted);
    cursor: not-allowed;
}

.btn-secondary {
    background: transparent;
    color: var(--text-primary);
    border-color: var(--border);
}

.btn-secondary:hover {
    border-color: var(--brand-red);
    color: var(--brand-red);
}

.btn-secondary:disabled {
    color: var(--text-muted);
    border-color: var(--border);
    cursor: not-allowed;
}

/* ── Form controls ───────────────────────────────────────────────────── */

label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
}

select,
input {
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9375rem;
    transition: border-color 0.15s, box-shadow 0.15s;
}

select:focus,
input:focus {
    outline: none;
    border-color: var(--brand-red);
    box-shadow: 0 0 0 3px var(--focus-ring);
}

select { cursor: pointer; }

/* ── Cards ───────────────────────────────────────────────────────────── */

.card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: clamp(1rem, 1vw + 0.75rem, 1.5rem);
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
    transition: background 0.2s ease, border-color 0.2s ease;
}

.card-title {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--text-primary);
    letter-spacing: -0.005em;
}

.card-subtitle {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
    font-weight: 400;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
    gap: 1rem;
    flex-wrap: wrap;
}

/* ── Grid (Pure Storage calculator page) ─────────────────────────────── */

/* Sidebar calculator + charts. The sidebar fluidly scales between 300 and
   380px as the viewport grows; below 1100px it stacks so charts get the
   full column width on laptop-class displays. */
.grid {
    display: grid;
    grid-template-columns: clamp(300px, 26vw, 380px) minmax(0, 1fr);
    gap: clamp(1rem, 1.5vw, 1.5rem);
}

@media (max-width: 1100px) {
    .grid { grid-template-columns: 1fr; }
}

.calculator {
    display: flex;
    flex-direction: column;
    gap: 1.125rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.result-panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    padding: 1.125rem;
    margin-top: 0.5rem;
}

.result-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-subtle);
}

.result-row:last-child { border-bottom: none; }

.result-label {
    color: var(--text-secondary);
    font-size: 0.8125rem;
}

.result-value {
    font-weight: 600;
    font-size: 0.9375rem;
    color: var(--text-primary);
}

.result-value.highlight {
    color: var(--brand-red);
    font-size: 1.25rem;
    font-weight: 700;
}

.band-info {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.875rem;
}

.band-chip {
    padding: 0.25rem 0.75rem;
    background: transparent;
    border-radius: 100px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.band-chip.active {
    background: var(--brand-red);
    color: #FFFFFF;
    border-color: var(--brand-red);
}

/* ── Chart surfaces ──────────────────────────────────────────────────── */

.charts-area {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Default to single column — keeps chart widths comfortable at the common
   1280–1440 viewport range. Only split to two columns on very wide monitors
   where each chart still has room to breathe (>1800px). */
.charts-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

@media (min-width: 1800px) {
    .charts-grid { grid-template-columns: 1fr 1fr; }
}

.chart-container {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: clamp(1rem, 1vw + 0.75rem, 1.5rem);
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.5rem;
    transition: background 0.2s ease, border-color 0.2s ease;
    /* Establish a query container so chart panels can adapt to their own
       width rather than the viewport. See .chart-wrapper @container rules. */
    container-type: inline-size;
    container-name: chart-panel;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.chart-title {
    font-size: 1.0625rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.chart-subtitle {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

/* Aspect-ratio drives height from the chart panel's own width, so the
   chart stays well-proportioned as the column grows or shrinks. min/max
   keep it sensible on extreme viewports; the @container rules below
   tighten the ratio when the panel is narrow (short & wide feels wrong
   on a skinny column) and relax it on wide panels. */
.chart-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 7;
    min-height: 260px;
    max-height: 480px;
}

.chart-wrapper.tall {
    aspect-ratio: 16 / 9;
    min-height: 320px;
    max-height: 560px;
}

@container chart-panel (max-width: 640px) {
    .chart-wrapper      { aspect-ratio: 4 / 3;  min-height: 280px; }
    .chart-wrapper.tall { aspect-ratio: 5 / 4;  min-height: 320px; }
}

@container chart-panel (min-width: 1100px) {
    .chart-wrapper      { aspect-ratio: 16 / 6; max-height: 520px; }
    .chart-wrapper.tall { aspect-ratio: 16 / 8; max-height: 600px; }
}

.legend-custom {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 1rem;
    justify-content: center;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.legend-color {
    width: 14px;
    height: 3px;
    border-radius: 2px;
}

/* ── Tabs (NC2 price view toggle) ────────────────────────────────────── */

.tabs {
    display: inline-flex;
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    padding: 0.25rem;
    gap: 0.25rem;
}

.tab {
    padding: 0.5rem 1rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.8125rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.tab:hover { color: var(--text-primary); }

.tab.active {
    background: var(--brand-red);
    color: #FFFFFF;
}

/* ── Chips / filters (Memory + shared) ───────────────────────────────── */

.filter-row {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.filter-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.04em;
    min-width: 60px;
}

.filter-chips {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.capacity-chip,
.term-btn,
.service-tab {
    padding: 0.375rem 0.875rem;
    border: 1px solid var(--border);
    border-radius: 100px;
    background: transparent;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

.capacity-chip:hover,
.term-btn:hover,
.service-tab:hover {
    border-color: var(--brand-red);
    color: var(--brand-red);
}

.capacity-chip.active,
.term-btn.active,
.service-tab.active {
    background: var(--brand-red);
    border-color: var(--brand-red);
    color: #FFFFFF;
}

.term-btn {
    border-radius: var(--radius-sm);
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
}

.term-selector {
    display: flex;
    gap: 0.375rem;
    flex-wrap: wrap;
}

.service-tabs {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-subtle);
}

.service-tab {
    border-radius: var(--radius-sm);
}

/* ── Data tables ─────────────────────────────────────────────────────── */

.data-table-wrapper {
    overflow-x: auto;
    margin: 0 -0.5rem;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.data-table th {
    text-align: left;
    padding: 0.75rem 0.875rem;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.75rem;
    letter-spacing: 0.03em;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
    white-space: nowrap;
}

.data-table td {
    padding: 0.75rem 0.875rem;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-primary);
}

.data-table tr:last-child td { border-bottom: none; }

.data-table tr:hover td { background: var(--surface-hover); }

.data-table th.num,
.data-table td.num {
    text-align: right;
}

.price-highlight {
    color: var(--brand-red);
    font-weight: 700;
}

.price-muted {
    color: var(--text-secondary);
}

.mono {
    font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, monospace;
    font-size: 0.8125rem;
}

/* ── States ──────────────────────────────────────────────────────────── */

.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: var(--text-secondary);
}

.spinner {
    width: 24px;
    height: 24px;
    border: 2px solid var(--border);
    border-top-color: var(--brand-red);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 0.75rem;
}

@keyframes spin { to { transform: rotate(360deg); } }

.no-data {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
}
