/* Variables */
:root {
    --sidebar-width: 240px;
    --header-height: 60px;
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-sidebar: #1a1a2e;
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --text-sidebar: #a0a0a0;
    --text-sidebar-active: #ffffff;
    --border-color: #e9ecef;
    --accent-color: #4f46e5;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
}

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

html, body {
    height: 100%;
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-secondary);
}

/* Admin Layout */
.admin-wrapper {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-brand {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-sidebar-active);
    letter-spacing: -0.5px;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar-nav .nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    color: var(--text-sidebar);
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.15s ease;
}

.sidebar-nav .nav-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-sidebar-active);
}

.sidebar-nav .nav-item.active {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-sidebar-active);
}

.sidebar-nav .nav-item i {
    font-size: 18px;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-sidebar);
    font-size: 13px;
    overflow: hidden;
}

.user-info span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.logout-btn {
    color: var(--text-sidebar);
    padding: 8px;
    border-radius: 6px;
    transition: all 0.15s ease;
}

.logout-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-sidebar-active);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.content-header {
    height: var(--header-height);
    padding: 0 32px;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
}

.page-title {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
    color: var(--text-primary);
}

.content-body {
    flex: 1;
    padding: 24px 32px;
    overflow-y: auto;
}

/* Auth Layout */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
}

/* Cards */
.card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
}

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

.card-header h3 {
    font-size: 14px;
    font-weight: 600;
    margin: 0;
    color: var(--text-primary);
}

.card-body {
    padding: 20px;
}

/* Dashboard */
.dashboard {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
}

@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.stats-grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

@media (max-width: 1024px) {
    .stats-grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .stats-grid,
    .stats-grid-4 {
        grid-template-columns: 1fr;
    }
}

.stats-block + .stats-block {
    margin-top: 20px;
}

.stats-heading {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    margin: 0 0 10px;
}

.stats-period {
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    margin-left: 8px;
}

.stats-footnote {
    font-size: 12px;
    color: var(--text-secondary);
    margin: 12px 0 0;
}

.stat-link {
    text-decoration: none;
    color: inherit;
    transition: border-color 0.15s ease;
}

.stat-link:hover {
    border-color: var(--accent-color);
    color: inherit;
}

.stat-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-icon {
    width: 48px;
    height: 48px;
    background: rgba(79, 70, 229, 0.1);
    color: var(--accent-color);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.stat-icon.success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success-color);
}

.stat-icon.warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning-color);
}

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}

.stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Activity */
.activity-list {
    display: flex;
    flex-direction: column;
}

.activity-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-dot {
    width: 8px;
    height: 8px;
    background: var(--success-color);
    border-radius: 50%;
    margin-top: 6px;
    flex-shrink: 0;
}

.activity-content {
    flex: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.activity-text {
    color: var(--text-primary);
}

.activity-time {
    color: var(--text-secondary);
    font-size: 12px;
}

/* Info List */
.info-list {
    display: flex;
    flex-direction: column;
}

.info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
}

.info-item:last-child {
    border-bottom: none;
}

.info-label {
    color: var(--text-secondary);
}

.info-value {
    color: var(--text-primary);
    font-weight: 500;
}

/* Buttons */
.btn-icon {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.btn-icon:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* Loading */
.loading-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.spinner {
    width: 24px;
    height: 24px;
    border: 2px solid var(--border-color);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Empty State */
.empty-state {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

/* HTMX */
.htmx-indicator {
    display: none;
}

.htmx-request .htmx-indicator {
    display: block;
}

.htmx-request.htmx-indicator {
    display: block;
}

/* ---------------------------------------------------------------------------
   Data visualisation
   One series per chart, so every fill is the same blue; identity is carried by
   the row label, not by a rainbow. Status colours are reserved for state and
   always ship next to a label.
   --------------------------------------------------------------------------- */
:root {
    --viz-series-1: #2a78d6;
    --viz-track: #eef1f6;
    --viz-good: #0ca30c;
    --viz-warning: #fab219;
    --viz-critical: #d03b3b;
    --viz-muted: #9a9a94;
}

.viz-bar-table th,
.viz-bar-table td {
    vertical-align: middle;
}

.viz-bar-track {
    height: 8px;
    min-width: 40px;
    background: var(--viz-track);
    border-radius: 4px;
    overflow: hidden;
}

.viz-bar-fill {
    height: 100%;
    background: var(--viz-series-1);
    border-radius: 0 4px 4px 0;
    transition: width 0.3s ease;
}

/* Monthly column chart — CSS columns rather than a charting library, since the
   series is a dozen points and needs no scales beyond "tallest bar is 100%". */
.viz-columns {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    height: 200px;
}

.viz-column {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    min-width: 0;
    height: 100%;
}

.viz-column-value {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-align: center;
    height: 1.1rem;
    line-height: 1.1rem;
}

.viz-column-track {
    flex: 1 1 auto;
    display: flex;
    align-items: flex-end;
    border-bottom: 1px solid var(--border-color);
}

.viz-column-fill {
    width: 100%;
    background: var(--viz-series-1);
    border-radius: 4px 4px 0 0;
    min-height: 2px;
}

.viz-column-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-align: center;
    padding-top: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* A missing hour has to look different from an hour that collected zero rows — the first is
   a run that never happened, the second is a run that found nothing. */
.viz-column-track-missing {
    background: repeating-linear-gradient(
        45deg,
        rgba(208, 59, 59, 0.10),
        rgba(208, 59, 59, 0.10) 3px,
        transparent 3px,
        transparent 6px
    );
}

.viz-column-fill-warning {
    background: var(--viz-warning);
}

.viz-swatch {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    display: inline-block;
    flex: 0 0 auto;
}

.viz-swatch-good { background: var(--viz-good); }
.viz-swatch-warning { background: var(--viz-warning); }
.viz-swatch-critical { background: var(--viz-critical); }
.viz-swatch-muted { background: var(--viz-muted); }

/* ---------------------------------------------------------------------------
   POI map
   The glyph inside a pin always names the category; the fill carries whichever
   dimension the "colour by" switch selects. Neither meaning rests on colour
   alone — the legend labels every entry and the popup spells both out.
   Pin fill and ink are set inline by the map script.
   --------------------------------------------------------------------------- */
#poi-map {
    height: 70vh;
    min-height: 420px;
    border-radius: 8px;
}

.poi-pin {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 2px solid #ffffff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
    font-size: 13px;
}

.poi-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 20px;
    align-items: center;
}

.poi-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.poi-legend-pin {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid #ffffff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    flex: 0 0 auto;
}

/* ---------------------------------------------------------------------------
   News article preview

   The body of a collected article is a third party's own HTML, sanitised at
   collection time and rendered as-is. Publishers size their markup for their
   own layout, so it has to be boxed here — an image at its native 2000px would
   otherwise push the whole panel sideways.
   --------------------------------------------------------------------------- */

.news-content img {
    max-width: 100%;
    height: auto;
    border-radius: 0.375rem;
}

.news-content table {
    width: 100%;
}

.news-content pre {
    white-space: pre-wrap;
    word-break: break-word;
}

.news-content h1,
.news-content h2,
.news-content h3 {
    font-size: 1.25rem;
    margin-top: 1.25rem;
}
