/* ══════════════════════════════════════════════════════════════
   BreezyTrade — Main Stylesheet
   ══════════════════════════════════════════════════════════════ */

/* ── CSS Custom Properties ── */
:root {
    --primary: #2563eb;
    --secondary: #7c3aed;
    --positive: #16a34a;
    --negative: #dc2626;
    --neutral: #6b7280;
    --bg: #f1f5f9;
    --card-bg: #f8fafc;
    --grid: #e5e7eb;
    --sidebar-width: 240px;
    --sidebar-bg: #0f172a;
    --header-bg: linear-gradient(135deg, #1e293b 0%, #334155 100%);
}

/* ── Reset ── */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: #1e293b;
    line-height: 1.5;
}

/* ══════════════════════════════════════════════════════════════
   LAYOUT: Sidebar + Main Content
   ══════════════════════════════════════════════════════════════ */

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

/* ── Sidebar ── */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: #e2e8f0;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    transition: left 0.3s ease;
}

.sidebar-header {
    padding: 1.25rem 1.25rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-logo {
    font-size: 1.2rem;
    font-weight: 800;
    color: white;
    letter-spacing: -0.02em;
}

.sidebar-close {
    display: none;
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0 0.25rem;
}

.sidebar-nav {
    list-style: none;
    padding: 0.5rem 0;
    flex: 1;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1.25rem;
    color: #94a3b8;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    border-left: 3px solid transparent;
    transition: color 0.2s, background 0.2s, border-color 0.2s;
}

.sidebar-link:hover {
    color: #e2e8f0;
    background: rgba(255,255,255,0.05);
}

.sidebar-link.active {
    color: white;
    background: rgba(37,99,235,0.15);
    border-left-color: var(--primary);
    font-weight: 600;
}

.sidebar-icon {
    font-size: 1.1rem;
    width: 1.5rem;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(255,255,255,0.08);
    font-size: 0.7rem;
    color: #64748b;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99;
}

/* ── Main Content Area ── */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-width: 0;
}

/* ── App Header (top bar) ── */
.app-header {
    background: var(--header-bg);
    color: white;
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 50;
}

.hamburger {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    margin-right: 0.75rem;
}

.header-info {
    font-size: 0.82rem;
    opacity: 0.7;
}

.header-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 0.1rem;
}

/* ── Filter Bar ── */
.filter-bar {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.filter-bar select {
    background: rgba(255,255,255,0.12);
    color: white;
    border: 1px solid rgba(255,255,255,0.25);
    border-radius: 20px;
    padding: 0.4rem 0.9rem;
    font-size: 0.8rem;
    font-family: inherit;
    cursor: pointer;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='white' viewBox='0 0 16 16'%3E%3Cpath d='M1.5 5.5l6.5 6.5 6.5-6.5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.6rem center;
    padding-right: 1.8rem;
}

.filter-bar select:hover {
    background-color: rgba(255,255,255,0.2);
}

.filter-bar select option {
    background: #1e293b;
    color: white;
}

/* ── Tab Content ── */
.tab-content {
    padding: 1.5rem;
    max-width: 1400px;
    margin: 0 auto;
}

/* ══════════════════════════════════════════════════════════════
   COMPONENTS: Sections, Cards, Tables, Charts
   ══════════════════════════════════════════════════════════════ */

/* ── Sections ── */
.section {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.section h2 {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #e2e8f0;
}

/* ── Cards Grid ── */
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.card {
    background: var(--card-bg);
    border-radius: 8px;
    padding: 1rem;
    text-align: center;
}

.card-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--neutral);
    margin-bottom: 0.25rem;
}

.card-value {
    font-size: 1.25rem;
    font-weight: 700;
}

.card-sub {
    font-size: 0.7rem;
    color: var(--neutral);
}

.card[title] {
    cursor: help;
}

/* ── Data Tables ── */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.data-table th, .data-table td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid #e5e7eb;
}

.data-table th {
    text-align: left;
    font-weight: 600;
    color: var(--neutral);
    font-size: 0.75rem;
    text-transform: uppercase;
}

.data-table tbody tr:hover {
    background: #f8fafc;
}

h3 {
    font-size: 1rem;
    margin: 1.5rem 0 0.75rem 0;
}

/* ── Chart Containers ── */
.chart-container {
    width: 100%;
    min-height: 300px;
    position: relative;
}

.chart-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.chart-full { width: 100%; }

.chart-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    color: var(--neutral);
    font-style: italic;
}

/* ══════════════════════════════════════════════════════════════
   TODAY TAB: Window Selector
   ══════════════════════════════════════════════════════════════ */

.window-selector {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
}

.window-btn {
    padding: 6px 18px;
    border-radius: 6px;
    border: 1px solid #334155;
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.window-btn:hover {
    color: #e2e8f0;
    border-color: #64748b;
}

.window-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.no-data {
    text-align: center;
    color: #64748b;
    padding: 32px 0;
    font-style: italic;
}

/* ══════════════════════════════════════════════════════════════
   TODAY TAB: Header Banner
   ══════════════════════════════════════════════════════════════ */

.today-header {
    background: linear-gradient(135deg, #0f172a 0%, #1e3a2f 50%, #1a3a1a 100%);
    border-radius: 12px;
    padding: 1.5rem 2rem;
    margin-bottom: 1.5rem;
    color: white;
}

.today-hero {
    text-align: center;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    margin-bottom: 1.25rem;
}

.today-hero-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #94a3b8;
    margin-bottom: 0.25rem;
}

.today-hero-value {
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.today-hero-change {
    font-size: 1.1rem;
    font-weight: 600;
    margin-top: 0.25rem;
}

.today-hero-period {
    font-size: 0.75rem;
    color: #94a3b8;
    font-weight: 400;
    margin-left: 0.5rem;
}

.today-metrics-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}

.today-metric {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.today-metric-icon {
    font-size: 1.25rem;
    margin-top: 2px;
}

.today-metric-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #94a3b8;
}

.today-metric-value {
    font-size: 1.05rem;
    font-weight: 700;
}

.today-metric-sub {
    font-size: 0.7rem;
    color: #94a3b8;
}

/* ══════════════════════════════════════════════════════════════
   TODAY TAB: Big Movers
   ══════════════════════════════════════════════════════════════ */

.movers-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.movers-label {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.movers-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

.movers-table th {
    text-align: right;
    font-weight: 600;
    color: var(--neutral);
    font-size: 0.7rem;
    text-transform: uppercase;
    padding: 0.35rem 0.5rem;
    border-bottom: 2px solid #e2e8f0;
}

.movers-table th:first-child { text-align: left; }

.mover-row td {
    padding: 0.4rem 0.5rem;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}

.mover-symbol {
    text-align: left;
    white-space: nowrap;
}

.mover-acct {
    display: inline-block;
    font-size: 0.65rem;
    color: #94a3b8;
    background: #f1f5f9;
    padding: 0px 5px;
    border-radius: 3px;
    margin-left: 4px;
    font-weight: 500;
}

.mover-bar-cell {
    width: 40%;
    padding-right: 0.5rem;
}

.mover-bar {
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    white-space: nowrap;
}

.mover-pct {
    text-align: right;
    font-weight: 600;
    white-space: nowrap;
}

.mover-weight {
    text-align: right;
    color: var(--neutral);
    font-size: 0.75rem;
}

.mover-qty {
    text-align: right;
    color: var(--neutral);
    font-size: 0.8rem;
    white-space: nowrap;
}

/* ══════════════════════════════════════════════════════════════
   TODAY TAB: Market Indices
   ══════════════════════════════════════════════════════════════ */

.idx-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.idx-table th {
    text-align: right;
    font-weight: 600;
    color: var(--neutral);
    font-size: 0.7rem;
    text-transform: uppercase;
    padding: 0.4rem 0.75rem;
    border-bottom: 2px solid #e2e8f0;
}

.idx-table th:first-child { text-align: left; }

.idx-table td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}

.idx-name {
    text-align: left;
    font-weight: 500;
    white-space: nowrap;
}

.idx-bar-cell {
    width: 60%;
}

.idx-bar {
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.85rem;
    white-space: nowrap;
    display: inline-block;
    min-width: 60px;
}

.idx-portfolio td {
    background: #f8fafc;
    font-weight: 600;
}

.idx-portfolio .idx-name {
    font-weight: 700;
}

/* ══════════════════════════════════════════════════════════════
   HTMX Loading States
   ══════════════════════════════════════════════════════════════ */

.htmx-indicator {
    display: none;
}

.htmx-request .htmx-indicator {
    display: block;
}

.htmx-request.tab-content > *:not(.htmx-indicator) {
    opacity: 0.5;
    transition: opacity 0.2s;
}

/* Loading spinner */
.loading-spinner {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: var(--neutral);
    font-style: italic;
}

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE: Mobile (≤1024px)
   ══════════════════════════════════════════════════════════════ */

@media (max-width: 1024px) {
    .sidebar {
        left: calc(-1 * var(--sidebar-width) - 20px);
    }

    .sidebar.open {
        left: 0;
    }

    .sidebar.open + .sidebar-overlay {
        display: block;
    }

    .sidebar-close {
        display: block;
    }

    .main-content {
        margin-left: 0;
    }

    .hamburger {
        display: block;
    }
}

@media (max-width: 768px) {
    .today-metrics-row {
        grid-template-columns: repeat(2, 1fr);
    }

    .movers-grid {
        grid-template-columns: 1fr;
    }

    .today-hero-value {
        font-size: 2rem;
    }

    .tab-content {
        padding: 1rem;
    }

    .app-header {
        padding: 0.75rem 1rem;
    }

    .filter-bar {
        flex-wrap: wrap;
    }
}

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

    .cards {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    }
}
