/* =============================================================================
   Polymarket Analytics - Component Styles
   Buttons, Badges, Cards, Tables, Forms, etc.
============================================================================= */

/* ---------- BUTTONS ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-weight: 500;
    transition: var(--transition);
    cursor: pointer;
    white-space: nowrap;
}

.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-full { width: 100%; justify-content: center; }

.btn-primary {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    box-shadow: var(--shadow-accent);
}

.btn-outline {
    background: transparent;
    color: var(--accent);
    border: 1px solid var(--accent);
}

.btn-outline:hover { background: var(--accent-light); }

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover { background: var(--bg-card); color: var(--text-primary); }
.full-width { width: 100%; justify-content: center; }

/* ---------- BADGE ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--accent-light);
    color: var(--accent-hover);
}

.badge.green { background: var(--green-bg); color: var(--green); }
.badge.red { background: var(--red-bg); color: var(--red); }
.badge.amber { background: var(--amber-bg); color: var(--amber); }

/* ---------- STATS GRID ---------- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    transition: var(--transition);
}

.stat-card:hover {
    border-color: var(--border-light);
    box-shadow: var(--shadow);
}

.stat-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 1.7rem;
    font-weight: 700;
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
    letter-spacing: -0.02em;
}

.stat-change.positive { color: var(--green); }
.stat-change.negative { color: var(--red); }

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

.chart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.chart-body {
    padding: 16px 20px;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.loading-placeholder {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* ---------- TABLES ---------- */
.table-container { overflow-x: auto; }

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

.data-table thead th {
    padding: 12px 16px;
    text-align: left;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.data-table tbody tr {
    border-bottom: 1px solid var(--border);
    transition: var(--transition);
}

.data-table tbody tr:hover { background: var(--bg-card-hover); }

.data-table tbody td {
    padding: 12px 16px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.data-table tbody td:first-child {
    color: var(--text-primary);
    font-weight: 500;
}

.data-table .mono {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
}

/* Side/Outcome chips */
.chip {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.chip.up, .chip.yes, .chip.buy { background: var(--green-bg); color: var(--green); }
.chip.down, .chip.no, .chip.sell { background: var(--red-bg); color: var(--red); }

/* Address styling */
.address {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.78rem;
    color: var(--text-accent);
}

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px;
}

/* ---------- SEARCH BOX ---------- */
.search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 6px 12px;
}

.search-box svg { color: var(--text-muted); flex-shrink: 0; }

.search-box input {
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 0.85rem;
    width: 280px;
}

.search-box input::placeholder { color: var(--text-muted); }

/* ---------- FILTER BAR ---------- */
.filter-bar {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.filter-group label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.filter-group select {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 0.85rem;
    padding: 8px 12px;
    min-width: 150px;
    outline: none;
    cursor: pointer;
    transition: var(--transition);
}

.filter-group select:hover { border-color: var(--border-light); }
.filter-group select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }

/* ---------- MARKET LIST ---------- */
.market-list { margin-top: 0; }
.market-row:hover { cursor: pointer; }
.market-question {
    max-width: 350px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---------- MARKET DETAIL ---------- */
.market-detail { margin-bottom: 24px; }

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

.detail-header h2 {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
}

.detail-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.detail-stat {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
}

.detail-stat-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 4px;
}

.detail-stat-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
}

.detail-charts {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

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

/* ---------- TRADER ANALYSIS ---------- */
.strategy-profile { padding: 20px; }

.strategy-description {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 20px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    border-left: 3px solid var(--accent);
}

.strategy-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
}

.metric-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.metric-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    min-width: 120px;
}

.metric-bar {
    flex: 1;
    height: 6px;
    background: var(--bg-secondary);
    border-radius: 3px;
    overflow: hidden;
}

.metric-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.6s ease;
}

.metric-fill.buy { background: var(--green); }
.metric-fill.up { background: var(--blue); }

.metric-value {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
    min-width: 60px;
    text-align: right;
}

/* ---------- EMPTY STATE ---------- */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 60px 40px;
    color: var(--text-muted);
}

.empty-state svg { margin-bottom: 20px; opacity: 0.5; }
.empty-state h3 { color: var(--text-secondary); font-size: 1.1rem; margin-bottom: 8px; }
.empty-state p { max-width: 400px; font-size: 0.9rem; line-height: 1.7; margin-bottom: 24px; }

.preset-addresses {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

.preset-label { font-size: 0.8rem; color: var(--text-muted); }

.preset-btn {
    padding: 6px 14px;
    background: var(--accent-light);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    color: var(--text-accent);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.preset-btn:hover { background: var(--accent); color: white; border-color: var(--accent); }

/* ---------- WHALE FEED ---------- */
.whale-feed { padding: 8px; }

.whale-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 16px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    margin-bottom: 8px;
    background: var(--bg-card);
    transition: var(--transition);
}

.whale-item:hover { border-color: var(--border-light); background: var(--bg-card-hover); }
.whale-item.large { border-color: rgba(99, 102, 241, 0.3); }

.whale-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent-light);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.whale-icon svg { color: var(--accent); }
.whale-info { flex: 1; min-width: 0; }

.whale-info-top {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.whale-market {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.whale-meta {
    display: flex;
    gap: 12px;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.whale-meta .mono { font-family: 'JetBrains Mono', monospace; }

.whale-values {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

.whale-size {
    font-size: 1rem;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
    color: var(--text-primary);
}

.whale-pnl.positive { color: var(--green); }
.whale-pnl.negative { color: var(--red); }
.whale-pnl { font-size: 0.78rem; font-family: 'JetBrains Mono', monospace; }

/* ---------- BACKTEST ---------- */
.backtest-layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 24px;
}

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

.backtest-params {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    height: fit-content;
}

.backtest-params h3 {
    margin-bottom: 20px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.param-group { margin-bottom: 18px; }

.param-group label {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 6px;
}

.param-group input[type="text"],
.param-group select {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 0.85rem;
    padding: 9px 12px;
    outline: none;
    transition: var(--transition);
}

.param-group input[type="text"]:focus,
.param-group select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.range-input {
    display: flex;
    align-items: center;
    gap: 12px;
}

.range-input input[type="range"] {
    flex: 1;
    height: 4px;
    background: var(--bg-secondary);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
    -webkit-appearance: none;
}

.range-input input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    box-shadow: 0 0 8px var(--accent-glow);
}

.range-input span {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
    min-width: 45px;
    text-align: right;
}

.backtest-results {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    min-height: 400px;
}

.backtest-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.bt-stat-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 4px;
}

.bt-stat-value {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
}

/* ---------- EXECUTION METRICS ---------- */
.exec-metric {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 14px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    min-width: 100px;
}

.exec-metric-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.exec-metric-value {
    font-size: 20px;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
    color: var(--text-primary);
}

.exec-metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 10px;
    padding: 12px;
}

/* ---------- ACTIVITY HEATMAP ---------- */
.heatmap-grid {
    display: grid;
    grid-template-columns: repeat(24, 1fr);
    gap: 4px;
    padding: 12px;
}

.heatmap-cell {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: transform 0.15s ease;
    cursor: default;
}

.heatmap-cell:hover {
    transform: scale(1.1);
    z-index: 1;
}

/* ---------- CHART SECTION HEADER ---------- */
.chart-section-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 24px 0 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.chart-section-header h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    text-transform: none;
    letter-spacing: normal;
}

/* ---------- CHART GRID (2-column) ---------- */
.charts-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

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