/* assets/css/compare.css */

/* ─── Toolbar ────────────────────────────────────────────────────────────────── */
.cmp-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

/* ─── Search ─────────────────────────────────────────────────────────────────── */
.cmp-search-wrap {
    position: relative;
    flex: 1 1 260px;
    min-width: 200px;
    max-width: 380px;
}

.cmp-search-wrap::before {
    content: '';
    position: absolute;
    left: 11px;
    top: 50%;
    transform: translateY(-50%);
    width: 14px;
    height: 14px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%23888'%3E%3Cpath fill-rule='evenodd' d='M8 4a4 4 0 100 8 4 4 0 000-8zM2 8a6 6 0 1110.89 3.476l4.817 4.817a1 1 0 01-1.414 1.414l-4.816-4.816A6 6 0 012 8z' clip-rule='evenodd'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-size: contain;
    pointer-events: none;
}

.cmp-search-input {
    width: 100%;
    box-sizing: border-box;
    background: var(--hover-bg);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    padding: 8px 10px 8px 32px;
    border-radius: 20px;
    font-size: 13px;
    font-family: inherit;
    transition: border-color 0.15s;
}
.cmp-search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: var(--bg-card);
}
.cmp-search-input::placeholder { color: var(--text-muted); }

.cmp-search-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    max-height: 280px;
    overflow-y: auto;
    z-index: 9999;
    box-shadow: 0 10px 30px rgba(0,0,0,0.25);
}
.cmp-search-dropdown.open { display: block; }

.cmp-search-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 14px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
}
.cmp-search-item:last-child { border-bottom: none; }
.cmp-search-item:hover,
.cmp-search-item.active { background: rgba(41,98,255,0.08); }

.cmp-item-symbol {
    font-weight: 700;
    color: var(--primary-color);
    font-size: 13px;
    white-space: nowrap;
    flex-shrink: 0;
    min-width: 52px;
}
.cmp-item-symbol.is-index  { color: #FF6B35; }
.cmp-item-symbol.is-sector { color: var(--text-muted); font-weight: 500; font-size: 11px; min-width: 48px; }

.cmp-item-name {
    font-size: 11px;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ─── Chips (added series) ───────────────────────────────────────────────────── */
.cmp-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
    min-height: 0;
}

.cmp-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px 5px 8px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid currentColor;
    cursor: default;
    user-select: none;
}
.cmp-chip-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.cmp-chip-label { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmp-chip-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,0.15);
    color: inherit;
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
    padding: 0;
    flex-shrink: 0;
    transition: background 0.15s;
}
.cmp-chip-remove:hover { background: rgba(255,255,255,0.3); }

/* ─── Chart area ─────────────────────────────────────────────────────────────── */
#cmp-chart-container {
    width: 100%;
    height: 500px;
    position: relative;
    margin-top: 4px;
}
@media (max-width: 768px) { #cmp-chart-container { height: 340px; } }

#cmp-legend {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(0,0,0,0.55);
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 12px;
    line-height: 1.6;
    pointer-events: none;
    display: none;
    z-index: 10;
    max-width: 320px;
}
[data-theme="light"] #cmp-legend { background: rgba(255,255,255,0.88); color: #222; }

/* ─── Loading spinner ────────────────────────────────────────────────────────── */
.cmp-loading {
    display: none;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-muted);
    padding: 4px 0;
}
.cmp-loading.show { display: flex; }
.cmp-spinner {
    width: 14px; height: 14px;
    border: 2px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: cmp-spin 0.7s linear infinite;
}
@keyframes cmp-spin { to { transform: rotate(360deg); } }

/* ─── Max series notice ──────────────────────────────────────────────────────── */
.cmp-max-notice {
    font-size: 11px;
    color: var(--text-muted);
    font-style: italic;
}

/* ─── Data table ─────────────────────────────────────────────────────────────── */
.cmp-tbl-wrap {
    overflow-x: auto;
    overflow-y: visible;
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

#cmp-table th,
#cmp-table td { white-space: nowrap; }

#cmp-table td:first-child {
    position: sticky;
    left: 0;
    background: var(--bg-card);
    z-index: 1;
}

#cmp-table thead th {
    position: sticky;
    top: 64px; /* Keep header below sticky navbar */
    z-index: 20;
    background: var(--bg-card);
    box-shadow: inset 0 -1px 0 var(--border-color);
}

#cmp-table thead th:first-child { z-index: 21; }

#cmp-table tbody tr:hover td:first-child { background: var(--hover-bg); }

.cmp-td-empty { color: var(--text-muted); }

.cmp-table-note {
    font-size: 11px;
    color: var(--text-muted);
    margin: 8px 0 0;
    text-align: right;
}

/* ─── Mobile ─────────────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
    .cmp-search-wrap { max-width: 100%; }
}
