/* ═══════════════════════════════════════════
   SahamID Analyzer — Polished Dark UI
   ═══════════════════════════════════════════ */
:root {
    --bg: #06080f;
    --surface: #0d1117;
    --surface2: #161b27;
    --surface3: #1c2333;
    --border: #1e2635;
    --border2: #2a3447;
    --text: #e4e8f0;
    --text2: #8892a4;
    --text3: #4a5568;
    --blue: #3b82f6;
    --blue-dim: rgba(59,130,246,0.15);
    --green: #22c55e;
    --green-bg: rgba(34,197,94,0.1);
    --green-border: rgba(34,197,94,0.3);
    --red: #ef4444;
    --red-bg: rgba(239,68,68,0.1);
    --red-border: rgba(239,68,68,0.3);
    --yellow: #eab308;
    --yellow-bg: rgba(234,179,8,0.1);
    --purple: #a855f7;
    --orange: #f97316;
    --radius: 14px;
    --radius-sm: 8px;
    --radius-xs: 4px;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

/* ═══ TOPBAR ═══ */
.topbar {
    position: sticky; top: 0; z-index: 100;
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 28px; height: 58px;
    background: rgba(6, 8, 15, 0.92);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 10px; }
.logo { font-size: 22px; }
.brand-name { font-size: 19px; font-weight: 800; letter-spacing: -0.3px; }
.brand-name span { color: var(--blue); }
.badge {
    font-size: 9px; font-weight: 700; letter-spacing: 0.5px;
    background: linear-gradient(135deg, var(--blue), var(--purple));
    color: #fff; padding: 2px 7px; border-radius: 10px;
}

.nav-links { display: flex; gap: 2px; }
.nav-link {
    padding: 8px 16px; border-radius: var(--radius-sm);
    color: var(--text2); text-decoration: none;
    font-size: 13px; font-weight: 500;
    transition: all 0.15s;
}
.nav-link:hover { color: var(--text); background: var(--surface2); }
.nav-link.active { color: var(--blue); background: var(--blue-dim); }

.clock { font-size: 12px; color: var(--text3); font-variant-numeric: tabular-nums; }

/* ═══ MAIN ═══ */
.main { max-width: 1440px; margin: 0 auto; padding: 24px 28px; }

/* ═══ SEARCH ═══ */
.search-wrap { margin-bottom: 24px; }
.search-bar {
    position: relative;
    display: flex; align-items: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 40px;
    padding: 0 16px;
    max-width: 480px;
    transition: border-color 0.2s;
}
.search-bar:focus-within { border-color: var(--blue); }
.search-icon { color: var(--text3); flex-shrink: 0; }
.search-bar input {
    flex: 1; padding: 12px 10px;
    background: none; border: none; outline: none;
    color: var(--text); font-size: 14px; font-family: inherit;
}
.search-bar input::placeholder { color: var(--text3); }

.search-drop {
    position: absolute; top: calc(100% + 6px); left: 0; right: 0;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    max-height: 280px; overflow-y: auto;
    display: none; z-index: 200;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.search-drop.show { display: block; }
.sdrop-item {
    padding: 10px 16px; cursor: pointer;
    display: flex; justify-content: space-between;
    font-size: 13px; transition: background 0.1s;
}
.sdrop-item:hover { background: var(--surface3); }
.sdrop-item .sym { font-weight: 600; color: var(--blue); }
.sdrop-item .sname { color: var(--text2); font-size: 12px; }

.chips { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.chip {
    padding: 5px 14px; font-size: 12px; font-weight: 500;
    background: var(--surface2); border: 1px solid var(--border);
    border-radius: 20px; color: var(--text2);
    cursor: pointer; transition: all 0.15s; font-family: inherit;
}
.chip:hover { border-color: var(--blue); color: var(--blue); }
.chip.active { border-color: var(--blue); color: var(--blue); background: var(--blue-dim); }

/* ═══ PAGES ═══ */
.page { display: none; }
.page.active { display: block; }

/* ═══ HERO VERDICT ═══ */
.hero {
    display: flex; justify-content: space-between; align-items: stretch;
    background: linear-gradient(135deg, var(--surface) 0%, var(--surface2) 100%);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px 32px;
    margin-bottom: 20px;
    gap: 24px;
}

.hero-left { flex: 1; }
.hero-symbol { font-size: 36px; font-weight: 900; letter-spacing: -0.5px; line-height: 1.1; }
.hero-name { font-size: 13px; color: var(--text2); margin: 4px 0 12px; }
.hero-price-row { display: flex; align-items: baseline; gap: 12px; }
.hero-price { font-size: 40px; font-weight: 800; letter-spacing: -1px; }
.hero-change { font-size: 15px; font-weight: 600; padding: 3px 10px; border-radius: var(--radius-xs); }
.hero-change.up { color: var(--green); background: var(--green-bg); }
.hero-change.down { color: var(--red); background: var(--red-bg); }
.hero-perf { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.perf-pill {
    font-size: 11px; font-weight: 500; color: var(--text2);
    background: var(--surface3); padding: 2px 8px; border-radius: var(--radius-xs);
}

.hero-right {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    min-width: 220px; gap: 16px;
}

.signal-big {
    font-size: 32px; font-weight: 900;
    padding: 10px 28px; border-radius: var(--radius-sm);
    text-align: center; width: 100%;
    letter-spacing: -0.5px;
}
.signal-big.strong-buy { color: var(--green); background: var(--green-bg); border: 2px solid var(--green-border); }
.signal-big.buy { color: var(--green); background: var(--green-bg); border: 2px solid rgba(34,197,94,0.2); }
.signal-big.hold { color: var(--yellow); background: var(--yellow-bg); border: 2px solid rgba(234,179,8,0.2); }
.signal-big.sell { color: var(--red); background: var(--red-bg); border: 2px solid rgba(239,68,68,0.2); }
.signal-big.strong-sell { color: var(--red); background: var(--red-bg); border: 2px solid var(--red-border); }

.score-wrap { width: 100%; text-align: center; }
.score-track {
    height: 8px; border-radius: 4px; margin-bottom: 4px;
    background: linear-gradient(to right, var(--red), var(--yellow) 50%, var(--green));
    position: relative;
}
.score-fill {
    position: absolute; top: -3px; width: 14px; height: 14px;
    background: #fff; border-radius: 50%;
    transform: translateX(-50%);
    box-shadow: 0 1px 6px rgba(0,0,0,0.5);
    transition: left 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}
.score-labels {
    display: flex; justify-content: space-between;
    font-size: 9px; color: var(--text3); margin-bottom: 2px;
}
.score-num { font-size: 12px; font-weight: 600; color: var(--text2); }

@media (max-width: 768px) {
    .hero { flex-direction: column; padding: 20px; }
    .hero-right { min-width: auto; }
}

/* ═══ CHART ═══ */
.chart-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 20px; overflow: hidden;
}

.chart-toolbar {
    display: flex; justify-content: space-between; align-items: center;
    flex-wrap: wrap; gap: 10px;
    padding: 12px 18px;
    border-bottom: 1px solid var(--border);
}

.period-btns { display: flex; gap: 3px; }
.pbtn {
    padding: 5px 14px; font-size: 12px; font-weight: 500;
    background: none; border: 1px solid transparent;
    border-radius: var(--radius-xs); color: var(--text2);
    cursor: pointer; transition: all 0.15s; font-family: inherit;
}
.pbtn:hover { color: var(--text); background: var(--surface3); }
.pbtn.active { color: #fff; background: var(--blue); border-color: var(--blue); }

.overlay-toggles { display: flex; gap: 4px; }
.toggle {
    display: flex; align-items: center; gap: 5px;
    padding: 4px 10px; font-size: 11px; color: var(--text2);
    background: var(--surface2); border: 1px solid var(--border);
    border-radius: var(--radius-xs); cursor: pointer; transition: all 0.15s;
}
.toggle:hover { border-color: var(--text3); }
.toggle input { display: none; }
.toggle:has(input:checked) { color: var(--blue); border-color: var(--blue); background: var(--blue-dim); }

#priceChart { width: 100%; height: 400px; }

.sub-charts {
    display: grid; grid-template-columns: 1fr 1fr;
    border-top: 1px solid var(--border);
}
.sub-chart-wrap { position: relative; }
.sub-chart-label {
    position: absolute; top: 8px; left: 12px; z-index: 10;
    font-size: 10px; font-weight: 600; color: var(--text3);
    text-transform: uppercase; letter-spacing: 0.5px;
}
#rsiChart, #macdChart { width: 100%; height: 130px; }

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

/* ═══ ANALYSIS GRID ═══ */
.analysis-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 20px;
    margin-bottom: 20px;
}
@media (max-width: 768px) { .analysis-grid { grid-template-columns: 1fr; } }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}
.card-title {
    font-size: 13px; font-weight: 700;
    color: var(--text2); margin-bottom: 14px;
    display: flex; justify-content: space-between; align-items: center;
}

.signal-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 7px 0; border-bottom: 1px solid var(--border);
    font-size: 13px; gap: 8px;
}
.signal-row:last-child { border-bottom: none; }
.signal-row .s-name { flex: 1; }
.signal-row .s-val { font-weight: 600; font-size: 12px; }
.s-val.bull { color: var(--green); }
.s-val.bear { color: var(--red); }
.s-val.neut { color: var(--text3); }

.ind-table { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.ind-row {
    display: flex; justify-content: space-between;
    padding: 5px 0; border-bottom: 1px solid var(--border);
    font-size: 12px;
}
.ind-row:last-child { border-bottom: none; }
.ind-row label { color: var(--text3); }
.ind-row span { font-weight: 500; }

/* ═══ S/R ═══ */
.sr-visual { display: flex; flex-direction: column; gap: 6px; }
.sr-row {
    display: flex; justify-content: space-between; align-items: center;
    font-size: 13px; padding: 6px 12px; border-radius: var(--radius-xs);
}
.sr-row.res { background: var(--red-bg); color: var(--red); }
.sr-row.sup { background: var(--green-bg); color: var(--green); }
.sr-price { font-weight: 700; }

/* ═══ SCREENER ═══ */
.btn-scan {
    padding: 8px 18px; font-size: 13px; font-weight: 600;
    background: var(--blue); border: none; border-radius: var(--radius-sm);
    color: #fff; cursor: pointer; font-family: inherit;
    transition: opacity 0.15s;
}
.btn-scan:hover { opacity: 0.85; }
.btn-scan:disabled { opacity: 0.5; cursor: not-allowed; }

.scan-progress {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 0; margin-bottom: 8px;
    font-size: 13px; color: var(--text2);
}
.progress-bar { flex: 1; height: 6px; background: var(--surface3); border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--blue); border-radius: 3px; transition: width 0.3s; }

.data-tbl { width: 100%; border-collapse: collapse; }
.data-tbl th {
    text-align: left; padding: 10px 12px;
    font-size: 10px; font-weight: 600;
    color: var(--text3); text-transform: uppercase; letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
    background: var(--surface2);
}
.data-tbl td {
    padding: 10px 12px; font-size: 13px;
    border-bottom: 1px solid var(--border);
}
.data-tbl tr:hover td { background: var(--surface2); }
.empty-td { text-align: center; color: var(--text3); padding: 40px !important; font-size: 14px !important; }

.sym-link { font-weight: 700; color: var(--blue); cursor: pointer; }
.sym-link:hover { text-decoration: underline; }

.tag {
    display: inline-block; padding: 2px 10px; border-radius: 10px;
    font-size: 10px; font-weight: 700; text-transform: uppercase;
}
.tag.sb { color: var(--green); background: var(--green-bg); border: 1px solid var(--green-border); }
.tag.b { color: var(--green); background: var(--green-bg); border: 1px solid rgba(34,197,94,0.2); }
.tag.h { color: var(--yellow); background: var(--yellow-bg); border: 1px solid rgba(234,179,8,0.2); }
.tag.s { color: var(--red); background: var(--red-bg); border: 1px solid rgba(239,68,68,0.2); }
.tag.ss { color: var(--red); background: var(--red-bg); border: 1px solid var(--red-border); }

.score-bar-mini {
    width: 50px; height: 5px; background: var(--surface3);
    border-radius: 3px; overflow: hidden; display: inline-block;
}
.score-bar-mini i { display: block; height: 100%; border-radius: 3px; }
.score-bar-mini i.pos { background: var(--green); }
.score-bar-mini i.neg { background: var(--red); }

/* ═══ LLM Section ═══ */
.llm-card { margin-top: 20px; }
.btn-llm {
    padding: 8px 18px; font-size: 13px; font-weight: 600;
    background: linear-gradient(135deg, #8b5cf6, #6366f1);
    border: none; border-radius: var(--radius-sm);
    color: #fff; cursor: pointer; font-family: inherit;
    transition: opacity 0.15s;
}
.btn-llm:hover { opacity: 0.85; }
.btn-llm:disabled { opacity: 0.5; cursor: not-allowed; }

.llm-content {
    font-size: 14px; line-height: 1.7; color: var(--text);
    max-height: 600px; overflow-y: auto;
}
.llm-content h2 {
    font-size: 16px; font-weight: 700; color: var(--text);
    margin: 16px 0 8px; padding-bottom: 4px;
    border-bottom: 1px solid var(--border);
}
.llm-content h2:first-child { margin-top: 0; }
.llm-content h3 {
    font-size: 14px; font-weight: 600; color: var(--text);
    margin: 12px 0 6px;
}
.llm-content p { margin: 8px 0; }
.llm-content ul, .llm-content ol { margin: 8px 0; padding-left: 20px; }
.llm-content li { margin: 4px 0; }
.llm-content strong { color: var(--text); }
.llm-content em { color: var(--text2); }
.llm-content br { display: block; content: ""; margin: 4px 0; }

.llm-placeholder {
    color: var(--text3); font-style: italic;
    text-align: center; padding: 20px;
}

.llm-loading {
    display: flex; align-items: center; gap: 12px;
    padding: 20px; color: var(--text2); font-size: 14px;
    justify-content: center;
}

.btn-anlz {
    padding: 4px 10px; font-size: 11px; font-weight: 600;
    background: var(--surface3); border: 1px solid var(--border);
    border-radius: var(--radius-xs); color: var(--text2);
    cursor: pointer; font-family: inherit; transition: all 0.15s;
}
.btn-anlz:hover { border-color: var(--blue); color: var(--blue); }

/* ═══ OVERLAY ═══ */
.overlay {
    position: fixed; inset: 0; z-index: 999;
    background: rgba(6,8,15,0.8);
    display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 16px;
    color: var(--text2); font-size: 14px;
}

.spinner {
    width: 32px; height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--blue);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
