/* ============================================================
   HSR Watch Dashboard — Stylesheet
   Design: Refined utilitarian. Clean data hierarchy.
   ============================================================ */

:root {
    --bg: #f8f9fa;
    --bg-card: #ffffff;
    --bg-dark: #1a1a2e;
    --text: #2d3436;
    --text-muted: #6c757d;
    --text-light: #adb5bd;
    --border: #dee2e6;
    --border-light: #e9ecef;
    --accent: #0d6efd;
    --accent-hover: #0b5ed7;
    --red: #dc3545;
    --amber: #f59e0b;
    --green: #198754;
    --blue: #0d6efd;
    --purple: #6f42c1;
    --radius: 6px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.1);
    --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
    --font-mono: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
}

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

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
}

/* --- Layout --- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
    width: 220px;
    background: var(--bg-dark);
    color: #e0e0e0;
    padding: 1.25rem 0;
    position: fixed;
    top: 0; bottom: 0;
    overflow-y: auto;
    z-index: 100;
}
.sidebar .brand {
    padding: 0 1.25rem 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    margin-bottom: 0.75rem;
}
.sidebar .brand h1 {
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.5px;
}
.sidebar .brand small {
    font-size: 0.7rem;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 1px;
}
.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 1.25rem;
    color: #b0b0b0;
    text-decoration: none;
    font-size: 0.85rem;
    transition: background 0.15s, color 0.15s;
}
.sidebar nav a:hover { background: rgba(255,255,255,0.06); color: #fff; }
.sidebar nav a.active { background: rgba(13,110,253,0.15); color: var(--accent); border-left: 3px solid var(--accent); }
.sidebar nav .divider { height: 1px; background: rgba(255,255,255,0.06); margin: 0.5rem 1rem; }
.sidebar .user-info {
    position: absolute;
    bottom: 0;
    width: 100%;
    padding: 0.75rem 1.25rem;
    border-top: 1px solid rgba(255,255,255,0.08);
    font-size: 0.75rem;
    color: var(--text-light);
}
.main { margin-left: 220px; flex: 1; padding: 1.5rem 2rem; max-width: 1200px; }

/* --- Page header --- */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}
.page-header h2 { font-size: 1.35rem; font-weight: 600; }
.page-header .actions { display: flex; gap: 0.5rem; }

/* --- Stats bar --- */
.stats-bar {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    flex: 1;
    box-shadow: var(--shadow);
}
.stat-card .stat-value { font-size: 1.75rem; font-weight: 700; }
.stat-card .stat-label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }

/* --- Signal cards --- */
.signal-list { display: flex; flex-direction: column; gap: 0.5rem; }
.signal-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    box-shadow: var(--shadow);
    display: grid;
    grid-template-columns: 50px 1fr auto;
    gap: 1rem;
    align-items: start;
    transition: border-color 0.15s;
}
.signal-card:hover { border-color: var(--accent); }
.signal-card a { text-decoration: none; color: inherit; }
.signal-card .score-badge {
    width: 46px; height: 46px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.9rem; color: #fff;
}
.score-high .score-badge { background: var(--red); }
.score-medium .score-badge { background: var(--amber); color: #000; }
.score-low .score-badge { background: var(--blue); }
.score-minimal .score-badge { background: var(--text-light); }
.signal-card .signal-body h3 { font-size: 0.95rem; font-weight: 600; margin-bottom: 0.25rem; }
.signal-card .signal-body h3 a:hover { color: var(--accent); }
.signal-card .signal-body .summary { font-size: 0.85rem; color: var(--text-muted); line-height: 1.4; }
.signal-card .signal-meta {
    display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.4rem;
}

/* --- Tags & badges --- */
.tag {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 3px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.tag-procurement { background: #fce4ec; color: #c62828; }
.tag-funding { background: #e8f5e9; color: #2e7d32; }
.tag-consultant_need { background: #fff3e0; color: #e65100; }
.tag-p3 { background: #ede7f6; color: #4527a0; }
.tag-government { background: #e3f2fd; color: #1565c0; }
.tag-general { background: #f5f5f5; color: #616161; }
.tag-confirmed { background: #c8e6c9; color: #1b5e20; }
.tag-strong_indicator { background: #fff9c4; color: #f57f17; }
.tag-early_signal { background: #e0e0e0; color: #424242; }
.tag-act_now { background: var(--red); color: #fff; }
.tag-watch { background: var(--amber); color: #000; }
.tag-background { background: var(--border-light); color: var(--text-muted); }
.signal-card .signal-right { text-align: right; white-space: nowrap; font-size: 0.75rem; color: var(--text-muted); }

/* --- Buttons --- */
.btn {
    display: inline-flex; align-items: center; gap: 0.35rem;
    padding: 0.45rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    color: var(--text);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s;
}
.btn:hover { background: var(--border-light); }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger { background: var(--red); color: #fff; border-color: var(--red); }
.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.75rem; }
.btn-icon { padding: 0.35rem 0.5rem; }

/* --- Forms --- */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: 0.8rem; font-weight: 600; margin-bottom: 0.3rem; color: var(--text-muted); }
.form-control {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-family: var(--font);
    background: var(--bg-card);
    transition: border-color 0.15s;
}
.form-control:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(13,110,253,0.12); }
select.form-control { cursor: pointer; }
textarea.form-control { font-family: var(--font-mono); font-size: 0.8rem; resize: vertical; min-height: 120px; }
.form-row { display: flex; gap: 1rem; }
.form-row .form-group { flex: 1; }
.form-inline { display: flex; gap: 0.5rem; align-items: flex-end; }
.form-check { display: flex; align-items: center; gap: 0.4rem; font-size: 0.85rem; }
.form-check input[type="checkbox"] { width: 16px; height: 16px; }

/* --- Filter bar --- */
.filter-bar {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: flex-end;
}
.filter-bar .form-group { margin-bottom: 0; min-width: 120px; }
.filter-bar .form-control { padding: 0.35rem 0.6rem; font-size: 0.8rem; }

/* --- Tables --- */
.table-wrap {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}
table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
thead th {
    text-align: left;
    padding: 0.6rem 0.75rem;
    background: var(--bg);
    border-bottom: 2px solid var(--border);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
tbody td { padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--border-light); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(13,110,253,0.02); }

/* --- Flash messages --- */
.flash { padding: 0.6rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; font-size: 0.85rem; }
.flash-success { background: #d1e7dd; color: #0f5132; border: 1px solid #badbcc; }
.flash-error { background: #f8d7da; color: #842029; border: 1px solid #f5c2c7; }
.flash-info { background: #cff4fc; color: #055160; border: 1px solid #b6effb; }

/* --- Signal detail --- */
.detail-header {
    display: flex; gap: 1.5rem; align-items: flex-start;
    margin-bottom: 1.5rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--border);
}
.detail-header .score-badge { width: 60px; height: 60px; font-size: 1.2rem; flex-shrink: 0; }
.detail-header h2 { font-size: 1.2rem; margin-bottom: 0.3rem; }
.detail-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
}
.detail-section h3 { font-size: 0.85rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 0.75rem; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.detail-item label { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; }
.detail-item p { font-size: 0.9rem; margin-top: 0.15rem; }
.raw-content { max-height: 400px; overflow-y: auto; padding: 1rem; background: #f6f8fa; border-radius: var(--radius); font-family: var(--font-mono); font-size: 0.8rem; white-space: pre-wrap; word-break: break-word; }

/* --- Source cards --- */
.source-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 1rem; }
.source-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
}
.source-card.disabled { opacity: 0.55; }
.source-card .source-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 0.75rem; }
.source-card .source-header h3 { font-size: 0.95rem; font-weight: 600; }
.source-card .source-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; font-size: 0.8rem; }
.source-card .source-stats dt { color: var(--text-muted); font-size: 0.7rem; text-transform: uppercase; }
.source-card .source-stats dd { font-weight: 600; }
.source-card .source-actions { display: flex; gap: 0.4rem; margin-top: 0.75rem; padding-top: 0.75rem; border-top: 1px solid var(--border-light); }
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 0.3rem; }
.status-dot.ok { background: var(--green); }
.status-dot.error { background: var(--red); }
.status-dot.disabled { background: var(--text-light); }

/* --- Pagination --- */
.pagination { display: flex; gap: 0.25rem; justify-content: center; margin-top: 1.5rem; }
.pagination a, .pagination span {
    padding: 0.35rem 0.7rem; border: 1px solid var(--border); border-radius: var(--radius);
    font-size: 0.8rem; text-decoration: none; color: var(--text);
}
.pagination a:hover { background: var(--border-light); }
.pagination .active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* --- Login page --- */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--bg-dark); }
.login-box {
    background: var(--bg-card);
    border-radius: 8px;
    padding: 2.5rem;
    width: 100%;
    max-width: 380px;
    box-shadow: var(--shadow-lg);
}
.login-box h1 { font-size: 1.3rem; margin-bottom: 0.3rem; }
.login-box .subtitle { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 1.5rem; }
.login-box .btn { width: 100%; justify-content: center; padding: 0.6rem; }

/* --- Empty state --- */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 2.5rem; margin-bottom: 0.75rem; }
.empty-state p { font-size: 0.9rem; }

/* --- Utilities --- */
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.8rem; }
.text-xs { font-size: 0.7rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.flex { display: flex; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
