/**
 * Identity: Global CSS design tokens and layout system for the Bobby Terminal.
 * Dependencies: None (Vanilla CSS).
 * Contract: Defines the visual style, HUD overlays, and responsive grid layouts for the entire dashboard.
 */

:root {
    --bg-color: #0d1117;
    --sidebar-bg: #161b22;
    --text-primary: #c9d1d9;
    --text-secondary: #8b949e;
    --accent: #58a6ff;
    --border: #30363d;
    --card-bg: #161b22;
    --success: #3fb950;
    --warning: #d29922;
    --sidebar-width: 220px;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.layout {
    display: flex;
    width: 100%;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 20px 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.layout.collapsed .sidebar {
    width: 0;
    min-width: 0;
    padding: 20px 0;
    border-right: none;
}

.layout.collapsed .sidebar * {
    display: none !important;
}

/* MIDDLE SIDEBAR HANDLE */
.collapse-toggle {
    position: absolute;
    top: 50%;
    right: -10px;
    transform: translateY(-50%);
    background-color: var(--sidebar-bg);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    z-index: 100;
    width: 20px;
    height: 50px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.collapse-toggle:hover {
    color: var(--accent);
    background-color: var(--border);
    right: -12px;
}

.logo {
    font-weight: 800;
    font-size: 1.1rem;
    padding: 0 20px 20px 20px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
    letter-spacing: 1px;
    text-align: center;
}

.nav-links {
    list-style: none;
    padding: 20px 0;
    margin: 0;
    flex-grow: 1;
}

.nav-links li a {
    display: block;
    padding: 10px 20px;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    transition: background 0.2s, color 0.2s;
}

.nav-links li a:hover, .nav-links li a.active {
    background-color: rgba(88, 166, 255, 0.1);
    color: var(--accent);
    border-right: 3px solid var(--accent);
}

.nav-section {
    padding: 15px 20px 5px;
    font-size: 0.7rem;
    font-weight: 800;
    color: var(--text-secondary);
    opacity: 0.5;
    letter-spacing: 1.5px;
    text-transform: uppercase;
}

.mode-toggle-container {
    padding: 15px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.action-btn {
    background-color: #21262d;
    color: var(--text-primary);
    border: 1px solid var(--border);
    padding: 10px 12px;
    width: 100%;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.action-btn:hover {
    background-color: #30363d;
    border-color: var(--accent);
}

.action-btn.active {
    background-color: rgba(88, 166, 255, 0.1);
    border-color: var(--accent);
    color: var(--accent);
}

.action-btn.secondary {
    background-color: transparent;
    border-style: dashed;
    color: var(--text-secondary);
}

.action-btn.secondary:hover {
    border-style: solid;
    color: var(--text-primary);
}


.status-panel {
    padding: 15px;
    border-top: 1px solid var(--border);
}

.status-indicator {
    color: var(--success);
    font-weight: bold;
    font-size: 0.8rem;
    display: block;
    margin-bottom: 8px;
}

.status-indicator.busy {
    color: var(--warning);
}

#refresh-btn {
    background-color: var(--border);
    color: var(--text-primary);
    border: none;
    padding: 6px 10px;
    width: 100%;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.8rem;
    transition: background 0.2s;
}

.text-small {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-top: 8px;
}

.sidebar-footer {
    padding: 10px 0;
    font-size: 0.7rem;
    color: var(--text-secondary);
    opacity: 0.7;
    font-family: monospace;
    letter-spacing: 0.5px;
    border-top: 1px solid rgba(48, 54, 61, 0.5);
    margin-top: auto;
    text-align: center;
}

.expand-trigger {
    position: fixed;
    top: 50%;
    left: 0px;
    transform: translateY(-50%);
    display: none;
    background: var(--sidebar-bg);
    border: 1px solid var(--border);
    color: var(--accent);
    padding: 15px 5px;
    border-radius: 0 4px 4px 0;
    cursor: pointer;
    z-index: 100;
}

.layout.collapsed + .expand-trigger {
    display: block;
}

.main-content {
    flex-grow: 1;
    padding: 20px;
    overflow-y: auto;
}

.header-title {
    margin-top: 0;
    font-size: 1.4rem;
    font-weight: 600;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

/* HUB TAB NAVIGATION */
.hub-tabs {
    display: flex;
    gap: 30px;
    margin-bottom: 25px;
    border-bottom: 1px solid var(--border);
}

.hub-tab {
    padding: 12px 5px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 700;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.hub-tab:hover {
    color: var(--text-primary);
}

.hub-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.year-legend {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    font-size: 0.75rem;
    position: absolute;
    right: 0;
    bottom: 10px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.legend-color {
    width: 10px;
    height: 10px;
    border-radius: 2px;
}

.commodity-row {
    margin-bottom: 30px;
}

.commodity-row h3 {
    font-size: 1.1rem;
    color: var(--text-primary);
    margin-bottom: 15px;
    border-left: 3px solid var(--accent);
    padding-left: 10px;
}

.chart-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

/* HUD COMPONENT CHART CARD */
.chart-card {
    background-color: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0;
    height: 280px;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.chart-header-hud {
    position: absolute;
    top: 12px;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 1rem;
    font-weight: 800;
    color: #fff; /* BRIGHT WHITE FOR HUD */
    z-index: 10;
    pointer-events: none; /* CLICK THROUGH TO PLOTLY */
    text-shadow: 0 0 10px rgba(0,0,0,0.8), 0 0 5px rgba(0,0,0,1);
}

.chart-body {
    flex-grow: 1;
    position: relative;
    overflow: hidden;
}

.chart-body > div {
    height: 100%;
    width: 100%;
    position: relative; /* Anchor for .chart-inline-legend absolute positioning */
}

.chart-loading-overlay {
    position: absolute;
    inset: 0;
    background: var(--card-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    color: var(--text-secondary);
    z-index: 5;
}

/* INLINE SEASONALITY LEGEND — per chart, bottom center, below x-axis date labels */
.chart-inline-legend {
    position: absolute;
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 6px;
    align-items: center;
    z-index: 10;
    pointer-events: auto;
    white-space: nowrap;
}

.ili-item {
    display: flex;
    align-items: center;
    gap: 2px;
    cursor: pointer;
    user-select: none;
    font-size: 6px;
    color: #8b949e;
    transition: color 0.15s, opacity 0.15s;
}

.ili-item:hover {
    color: #c9d1d9;
}

.ili-item.ili-hidden {
    opacity: 0.3;
}

.ili-dot {
    width: 10px;
    height: 2px;
    border-radius: 1px;
    flex-shrink: 0;
}

@media (max-width: 1400px) {
    .chart-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 800px) {
    .chart-grid {
        grid-template-columns: 1fr;
    }
}