/* =============================================================================
   INDEX-BAR.CSS — Market Index Bar Component
   AI Supply Chain Dashboard
   Created: 2025-02-27

   PURPOSE: The horizontal bar of SPY/QQQ/DIA/TLT/etc cards appears at the
   top of universe.html, screener.html, and etf.html. The CSS was duplicated
   verbatim in each file. This is the single source of truth.

   COMPONENTS:
   - .index-bar          Flex container holding all index cards
   - .index-card         Individual card (price + change + extended hours)
   - .index-ext          Extended hours (pre/after market) section
   - Range bar & dot     52-week range indicator

   USAGE: @import './index-bar.css'; in any page that renders the index bar.
   Currently used by: universe, screener, etf.

   REVERT: Copy all rules below back inline into each page's <style> tag.
   ============================================================================= */

/* =============================================================================
   INDEX BAR WRAPPER
   ============================================================================= */
.index-bar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: stretch;
    margin-bottom: 16px;
}

/* =============================================================================
   INDEX CARD
   ============================================================================= */
.index-card {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    font-family: var(--font-data);
    transition: border-color 0.2s;
    min-width: 140px;
}

.index-card:hover {
    border-color: var(--border-mid);
}

.index-name {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-hi);
}

.index-label {
    font-size: 9px;
    color: var(--text-dim);
    flex: 1;
}

.index-main {
    display: flex;
    align-items: center;
    gap: 8px;
}

.index-price {
    font-size: 11px;
    color: var(--text-base);
}

.index-change {
    font-size: 11px;
    font-weight: 700;
    min-width: 54px;
}

.index-change.gain { color: var(--gain); }
.index-change.loss { color: var(--loss); }

/* =============================================================================
   EXTENDED HOURS SECTION (pre-market / after-hours)
   Separated from regular price by a vertical border.
   ============================================================================= */
.index-ext {
    display: flex;
    gap: 6px;
    align-items: center;
    border-left: 1px solid var(--border);
    padding-left: 10px;
    margin-left: 2px;
}

.index-ext-badge {
    font-size: 8px;
    color: var(--text-dim);
    background: #111118;
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 1px 5px;
    white-space: nowrap;
}

.index-ext-val {
    font-size: 9px;
    font-weight: 700;
    white-space: nowrap;
}

.index-ext-val.gain  { color: var(--gain); }
.index-ext-val.loss  { color: var(--loss); }
.index-ext-val.flat  { color: var(--text-dim); }

.index-ext-time {
    font-size: 8px;
    color: #3f3f46;
    margin-left: 2px;
}

/* =============================================================================
   52-WEEK RANGE BAR
   Shown inside index cards and table cells.
   <div class="range-bar"><div class="range-dot" style="left: 65%"></div></div>
   ============================================================================= */
.range-bar {
    width: 60px;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    position: relative;
    display: inline-block;
    vertical-align: middle;
}

.range-dot {
    position: absolute;
    top: -3px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--acc);
    border: 1px solid var(--bg);
    transform: translateX(-50%);
}

/* =============================================================================
   MULTI-SELECT DROPDOWN COMPONENT
   Used for Sector / Industry / ETF filter dropdowns.
   Shared between universe.html and screener.html.

   HTML structure:
   <div class="ms-wrap">
     <div class="ms-btn">Sector ▾</div>
     <div class="ms-drop">
       <label><input type="checkbox"> Technology</label>
     </div>
   </div>
   ============================================================================= */
.ms-wrap {
    position: relative;
    display: inline-block;
}

.ms-btn {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 3px 10px;
    font-family: var(--font-data);
    font-size: 9px;
    color: var(--text-mid);
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    user-select: none;
}

.ms-btn:hover,
.ms-btn.open          { border-color: var(--acc); color: var(--acc); }
.ms-btn.has-filter    { border-color: var(--acc); color: var(--acc); background: var(--acc-dim); }

.ms-drop {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 4px;
    background: #0e0e14;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 4px 0;
    z-index: 100;
    min-width: 180px;
    max-height: 240px;
    overflow-y: auto;
    box-shadow: 0 12px 40px rgba(0,0,0,0.7);
}

.ms-drop.show { display: block; }

.ms-drop label {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    font-size: 9px;
    color: var(--text-base);
    cursor: pointer;
    transition: background 0.1s;
}

.ms-drop label:hover         { background: rgba(255,255,255,0.04); }
.ms-drop input[type=checkbox] { accent-color: var(--acc); width: 11px; height: 11px; }

.ms-drop .ms-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}

/* =============================================================================
   SEARCH BOX — filter input field
   Shared across universe, screener, etf.
   ============================================================================= */
.search-box {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 5px 10px;
    font-family: var(--font-data);
    font-size: 10px;
    color: var(--text-hi);
    outline: none;
    transition: border-color 0.2s;
}

.search-box:focus       { border-color: var(--acc); }
.search-box::placeholder { color: #333; }

/* =============================================================================
   FILTER PILL TAGS — shown when filters are active
   e.g. "Sector: Technology ×"
   ============================================================================= */
.filter-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 8px;
    background: var(--acc-dim);
    border: 1px solid var(--acc-dim);
    border-radius: 4px;
    font-size: 8px;
    font-weight: 700;
    color: var(--acc);
    cursor: pointer;
    font-family: var(--font-data);
}

.filter-pill:hover { opacity: 0.75; }

/* =============================================================================
   SYNC PROGRESS BAR — shown during admin data sync
   ============================================================================= */
.sync-progress {
    height: 2px;
    background: var(--border);
    border-radius: 1px;
    overflow: hidden;
    margin-top: 4px;
}

.sync-progress-fill {
    height: 100%;
    background: var(--acc);
    border-radius: 1px;
    transition: width 0.3s ease;
    width: 0%;
}
