/* ============================================================
   Compaare — ETF Overlap Analyser
   ============================================================ */

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

:root {
    --bg:          #0f1117;
    --surface:     #1a1d27;
    --surface2:    #242736;
    --border:      #2e3246;
    --text:        #e2e5f0;
    --text-muted:  #7b82a0;
    --accent:      #6c7bff;
    --accent-dim:  #3d4699;
    --danger:      #ff5f6d;
    --radius:      8px;
    --font:        'Inter', system-ui, -apple-system, sans-serif;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.6;
    min-height: 100vh;
}

a { color: var(--accent); }
a:hover { opacity: .8; }

/* ---- Layout ---- */

.page-wrap {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 24px;
}

header {
    padding: 32px 0 24px;
    border-bottom: 1px solid var(--border);
}

header h1 {
    margin: 0 0 4px;
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -.5px;
}

header p {
    margin: 0;
    color: var(--text-muted);
    font-size: .9rem;
}

main { padding: 32px 0 64px; }

/* ---- Input card ---- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
}

.card + .card { margin-top: 20px; }

.card h2 {
    margin: 0 0 16px;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .06em;
}

/* ---- ISIN input ---- */

.input-row {
    display: flex;
    gap: 10px;
}

.input-row input[type="text"] {
    flex: 1;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: .95rem;
    padding: 10px 14px;
    outline: none;
    transition: border-color .15s;
}

.input-row input[type="text"]:focus {
    border-color: var(--accent);
}

.input-row input[type="text"]::placeholder {
    color: var(--text-muted);
}

.btn {
    background: var(--accent);
    border: none;
    border-radius: var(--radius);
    color: #fff;
    cursor: pointer;
    font-size: .95rem;
    font-weight: 600;
    padding: 10px 20px;
    transition: background .15s, opacity .15s;
    white-space: nowrap;
}

.btn:hover   { background: #8090ff; }
.btn:active  { opacity: .85; }
.btn:disabled { background: var(--border); cursor: not-allowed; }

.btn-ghost {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
}

.btn-ghost:hover { border-color: var(--accent); color: var(--accent); background: transparent; }

/* ---- ETF chips ---- */

.chip-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
}

.chip {
    align-items: center;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 20px;
    display: inline-flex;
    font-size: .85rem;
    gap: 6px;
    padding: 4px 12px 4px 10px;
}

.chip .dot {
    border-radius: 50%;
    display: inline-block;
    height: 8px;
    width: 8px;
    flex-shrink: 0;
}

.chip .remove {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    padding: 0;
}
.chip .remove:hover { color: var(--danger); }

/* ---- Analyse button row ---- */

.action-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 20px;
}

.action-row .hint {
    color: var(--text-muted);
    font-size: .85rem;
}

/* ---- Error / info messages ---- */

.msg {
    border-radius: var(--radius);
    font-size: .9rem;
    margin-top: 12px;
    padding: 10px 14px;
}

.msg-error { background: #2a1318; border: 1px solid #6b2030; color: #ff8a93; }
.msg-info  { background: #111b30; border: 1px solid #2b4080; color: #7eb0ff; }

/* ---- Chord diagram ---- */

#diagram-section { margin-top: 32px; }

#chord-container {
    display: flex;
    justify-content: center;
}

#chord-container svg { overflow: visible; }

/* D3 tooltip */
.chord-tooltip {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: .82rem;
    max-width: 240px;
    padding: 8px 12px;
    pointer-events: none;
    position: fixed;
    z-index: 100;
    line-height: 1.5;
}

.chord-tooltip strong { display: block; margin-bottom: 4px; }

/* ---- Holdings detail panel ---- */

#detail-panel {
    margin-top: 24px;
}

.detail-header {
    align-items: center;
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.detail-header h3 { margin: 0; font-size: 1rem; }

.holdings-table {
    border-collapse: collapse;
    font-size: .85rem;
    width: 100%;
}

.holdings-table th,
.holdings-table td {
    border-bottom: 1px solid var(--border);
    padding: 7px 10px;
    text-align: left;
}

.holdings-table th {
    color: var(--text-muted);
    font-weight: 500;
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .05em;
}

.holdings-table tr:last-child td { border-bottom: none; }
.holdings-table tr:hover td { background: var(--surface2); }

/* ---- Stats row ---- */

.stats-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    flex: 1;
    min-width: 140px;
    padding: 14px 18px;
}

.stat-card .label {
    color: var(--text-muted);
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .06em;
}

.stat-card .value {
    font-size: 1.6rem;
    font-weight: 700;
    margin-top: 4px;
}

/* ---- Disclaimer ---- */

.disclaimer {
    color: var(--text-muted);
    font-size: .78rem;
    margin-top: 28px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

/* ---- Spinner ---- */

.spinner {
    animation: spin .8s linear infinite;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    display: inline-block;
    height: 20px;
    width: 20px;
    vertical-align: middle;
}

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

/* ---- Responsive ---- */

@media (max-width: 600px) {
    .input-row { flex-direction: column; }
    .stats-row  { flex-direction: column; }
}
