/* News Platform — Modern dashboard styles (extends Pico CSS) */

:root {
    --brand-color: #1a2332;
    --brand-light: #243447;
    --accent-color: #2563eb;
    --accent-hover: #1d4ed8;
    --success-color: #16a34a;
    --warning-color: #f59e0b;
    --danger-color: #dc2626;
    --muted-color: #6b7280;
    --border-color: #e5e7eb;
    --bg-main: #f3f4f6;
    --bg-card: #ffffff;
    --text-primary: #111827;
    --text-secondary: #4b5563;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
    --shadow-hover: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.04);
    --radius: 10px;
}

body {
    background: var(--bg-main);
    color: var(--text-primary);
}

/* Layout */
.container {
    max-width: 1380px;
    margin: 0 auto;
    padding: 0 1.25rem;
}

/* Nav */
nav.top-nav {
    background: var(--brand-color);
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    height: 56px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

nav.top-nav a {
    color: #94a3b8;
    text-decoration: none;
    font-size: 0.875rem;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    transition: all 150ms ease;
}

nav.top-nav a:hover {
    color: #fff;
    background: var(--brand-light);
}

nav.top-nav .brand {
    font-weight: 700;
    font-size: 1.05rem;
    margin-right: auto;
    color: #fff;
    padding-left: 0;
    letter-spacing: -0.01em;
}

nav.top-nav button {
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    font-size: 0.875rem;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    transition: all 150ms ease;
}

nav.top-nav button:hover {
    color: #fff;
    background: var(--brand-light);
}

/* Dashboard header */
.dashboard-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
}

.dashboard-header--stacked {
    gap: 1.5rem;
    align-items: end;
}

.dashboard-header h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.dashboard-kicker {
    margin: 0 0 0.3rem;
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--accent-color);
    font-weight: 700;
}

.dashboard-subtitle {
    margin: 0.45rem 0 0;
    max-width: 62ch;
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.5;
}

.stats-bar {
    display: flex;
    gap: 1rem;
    font-size: 0.8rem;
    color: var(--muted-color);
    flex-wrap: wrap;
    margin-bottom: 0.85rem;
}

.stats-bar strong {
    color: var(--text-primary);
}

.stats-pill {
    background: #eff6ff;
    color: #1d4ed8;
    padding: 0.18rem 0.65rem;
    border-radius: 999px;
}

/* Filter bar */
.filter-bar {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
    align-items: end;
    background: var(--bg-card);
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.filter-group--wide {
    flex: 1;
    min-width: 220px;
}

.filter-group--actions {
    margin-left: auto;
}

.filter-reset {
    margin-bottom: 0;
    white-space: nowrap;
}

.monitor-tabs {
    display: flex;
    gap: 0.7rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.monitor-tab {
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
    text-decoration: none;
    padding: 0.7rem 0.95rem;
    border-radius: 999px;
    background: #fff;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.monitor-tab strong {
    display: inline-flex;
    min-width: 1.9rem;
    justify-content: center;
    padding: 0.12rem 0.5rem;
    border-radius: 999px;
    background: #eef2ff;
    color: #4338ca;
    font-size: 0.78rem;
}

.monitor-tab.active {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: #fff;
    border-color: #0f172a;
}

.monitor-tab.active strong {
    background: rgba(255,255,255,0.16);
    color: #fff;
}

.saved-view-strip {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 0.9rem 1rem;
    box-shadow: var(--shadow-sm);
    margin-bottom: 1rem;
}

.saved-view-strip__header {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
    margin-bottom: 0.75rem;
    font-size: 0.82rem;
    color: var(--muted-color);
    font-weight: 600;
}

.saved-view-strip__items {
    display: flex;
    gap: 0.55rem;
    flex-wrap: wrap;
}

.saved-view-chip {
    text-decoration: none;
    color: var(--text-primary);
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    padding: 0.4rem 0.8rem;
    font-size: 0.82rem;
}

.saved-view-chip.active {
    background: #dbeafe;
    border-color: #93c5fd;
    color: #1d4ed8;
}

.saved-view-empty {
    color: var(--muted-color);
    font-size: 0.85rem;
}

.save-view-form {
    min-width: min(100%, 360px);
}

.save-view-form label {
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted-color);
    font-weight: 700;
    margin-bottom: 0.45rem;
}

.save-view-row {
    display: flex;
    gap: 0.7rem;
    align-items: center;
}

.save-view-row input {
    margin-bottom: 0;
    background: #fff;
}

.dashboard-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 1.25rem;
    align-items: start;
}

.dashboard-feed {
    min-width: 0;
}

.article-preview-shell {
    position: sticky;
    top: 1rem;
}

.page-notice {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.page-notice--success {
    background: #e8f5e9;
    color: #166534;
}

.page-notice--error {
    background: #ffebee;
    color: #b91c1c;
}

.filter-bar .filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

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

.filter-bar select,
.filter-bar input[type="search"] {
    font-size: 0.85rem;
    padding: 0.45rem 0.7rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-main);
    color: var(--text-primary);
    min-width: 140px;
    transition: border-color 150ms ease;
    margin-bottom: 0;
}

.filter-bar select:focus,
.filter-bar input[type="search"]:focus {
    border-color: var(--accent-color);
    outline: none;
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

/* Article count */
.article-count {
    color: var(--muted-color);
    font-size: 0.8rem;
    margin-bottom: 0.75rem;
    font-weight: 500;
}

/* Article cards — modern horizontal layout with image */
.article-card {
    display: flex;
    gap: 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 0.6rem;
    background: var(--bg-card);
    box-shadow: var(--shadow-sm);
    transition: box-shadow 200ms ease, border-color 200ms ease;
}

.article-card--unread {
    border-left: 4px solid var(--accent-color);
}

.article-card--read {
    opacity: 0.92;
}

.article-card:hover {
    box-shadow: var(--shadow-hover);
    border-color: #d1d5db;
}

.article-thumb {
    flex-shrink: 0;
    width: 120px;
    height: 90px;
    border-radius: 8px;
    overflow: hidden;
    background: #f0f1f3;
    display: flex;
    align-items: center;
    justify-content: center;
}

.article-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.article-thumb .thumb-domain {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    font-size: 2rem;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    text-transform: uppercase;
}

.article-thumb .thumb-domain[data-source="mena"] {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
}

.article-thumb .thumb-domain[data-source="google"] {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.article-body {
    flex: 1;
    min-width: 0;
}

.article-card h3 {
    margin: 0 0 0.35rem;
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.35;
}

.article-card h3 a {
    color: var(--text-primary);
    text-decoration: none;
    transition: color 150ms ease;
}

.article-card h3 a:hover {
    color: var(--accent-color);
}

.article-topline {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: flex-start;
    margin-bottom: 0.55rem;
}

.article-badges {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.cluster-pill {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 0.15rem 0.65rem;
    font-size: 0.72rem;
    background: #fff7ed;
    color: #c2410c;
    border: 1px solid #fdba74;
}

/* Matched term tags */
.matched-terms {
    display: flex;
    gap: 0.3rem;
    flex-wrap: wrap;
    margin: 0 0 0.4rem;
    align-items: center;
}

.matched-term-label {
    font-size: 0.7rem;
    color: var(--muted-color);
    font-weight: 500;
}

.matched-term-tag {
    display: inline-block;
    background: #fef3c7;
    color: #b45309;
    border: 1px solid #fcd34d;
    border-radius: 4px;
    padding: 0.1rem 0.45rem;
    font-size: 0.72rem;
    font-weight: 600;
}

/* Meta row */
.article-meta {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
    font-size: 0.75rem;
    color: var(--muted-color);
    margin-bottom: 0.3rem;
}

.article-meta .separator {
    color: #d1d5db;
}

/* Pills / badges */
.pill {
    display: inline-flex;
    align-items: center;
    border-radius: 100px;
    padding: 0.12rem 0.55rem;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.01em;
}

.pill.source-mena {
    background: #dcfce7;
    color: #166534;
}

.pill.source-google {
    background: #ffedd5;
    color: #c2410c;
}

.pill.category {
    background: #ede9fe;
    color: #6d28d9;
}

.pill-starred {
    background: #fef3c7;
    color: #b45309;
}

.pill-unread {
    background: #dbeafe;
    color: #1d4ed8;
}

/* Summary */
.article-card .summary {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin: 0.25rem 0 0;
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Card footer */
.article-footer {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: flex-end;
    margin-top: 0.4rem;
}

/* Report button */
.btn-report,
.btn-inline {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--muted-color);
    padding: 0.2rem 0.55rem;
    border-radius: 5px;
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 150ms ease;
}

.btn-report:hover,
.btn-inline:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
    background: #eff6ff;
}

.btn-report:hover {
    border-color: var(--danger-color);
    color: var(--danger-color);
    background: #fef2f2;
}

.btn-inline-danger {
    background: none;
    border: none;
    padding: 0;
    color: var(--danger-color);
    cursor: pointer;
    font-size: 0.82rem;
}

.article-preview {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.15rem 1.2rem;
    box-shadow: var(--shadow-md);
}

.article-preview--empty {
    min-height: 260px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.article-preview__eyebrow {
    margin: 0 0 0.45rem;
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--accent-color);
    font-weight: 700;
}

.article-preview__top {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: start;
}

.article-preview__top h3 {
    margin: 0 0 0.6rem;
    font-size: 1.1rem;
    line-height: 1.35;
}

.article-preview__open {
    white-space: nowrap;
    text-decoration: none;
    color: var(--accent-color);
    font-weight: 600;
}

.article-preview__meta {
    margin: 0.75rem 0 0;
    color: var(--muted-color);
    font-size: 0.85rem;
}

.article-preview__summary {
    margin: 1rem 0;
    color: var(--text-secondary);
    line-height: 1.6;
}

.article-preview__actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin: 1rem 0 1.15rem;
}

.article-preview__related h4 {
    margin: 0 0 0.7rem;
    font-size: 0.95rem;
}

.article-preview__related ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
}

.article-preview__related li {
    display: flex;
    flex-direction: column;
    gap: 0.18rem;
    padding-top: 0.7rem;
    border-top: 1px solid #edf2f7;
}

.article-preview__related li:first-child {
    border-top: none;
    padding-top: 0;
}

.article-preview__related a {
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 600;
}

.article-preview__related span {
    color: var(--muted-color);
    font-size: 0.8rem;
}

/* Pagination */
.pagination {
    display: flex;
    gap: 0.4rem;
    justify-content: center;
    align-items: center;
    margin-top: 1.5rem;
    padding-bottom: 2rem;
}

.pagination a {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.4rem 0.85rem;
    font-size: 0.82rem;
    color: var(--accent-color);
    text-decoration: none;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    transition: all 150ms ease;
}

.pagination a:hover {
    background: #eff6ff;
    border-color: var(--accent-color);
}

.pagination .page-info {
    color: var(--muted-color);
    font-size: 0.8rem;
    padding: 0 0.5rem;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 4rem 1rem;
    color: var(--muted-color);
}

.empty-state p:first-child {
    font-size: 1.15rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.empty-state a {
    color: var(--accent-color);
}

/* Loading spinner */
.htmx-indicator {
    opacity: 0;
    transition: opacity 200ms ease-in;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
    opacity: 1;
}

.spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid var(--border-color);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    vertical-align: middle;
    margin-left: 0.5rem;
}

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

/* Toast notifications */
#toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 9999;
}

.toast {
    background: var(--brand-color);
    color: #fff;
    padding: 0.75rem 1.25rem;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    animation: toast-slide 4s ease-in-out forwards;
    font-size: 0.85rem;
    box-shadow: var(--shadow-md);
}

.toast.success { background: var(--success-color); }
.toast.warning { background: var(--warning-color); }
.toast.error { background: var(--danger-color); }

@keyframes toast-slide {
    0% { opacity: 0; transform: translateX(20px); }
    8% { opacity: 1; transform: translateX(0); }
    80% { opacity: 1; }
    100% { opacity: 0; }
}

/* Login page */
.login-container {
    max-width: 400px;
    margin: 4rem auto;
    padding: 2rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: var(--bg-card);
    box-shadow: var(--shadow-md);
}

/* Admin user list */
.user-table td, .user-table th {
    padding: 0.5rem 0.75rem;
}

/* Responsive */
@media (max-width: 640px) {
    .article-card {
        flex-direction: column;
    }
    .article-thumb {
        width: 100%;
        height: 160px;
    }
    .filter-bar {
        flex-direction: column;
        gap: 0.5rem;
    }
    .filter-bar select,
    .filter-bar input[type="search"] {
        min-width: auto;
        width: 100%;
    }
    .dashboard-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    .save-view-row {
        flex-direction: column;
        align-items: stretch;
    }
    .article-preview__top {
        flex-direction: column;
    }
    .article-footer {
        justify-content: flex-start;
    }
}

@media (max-width: 980px) {
    .dashboard-layout {
        grid-template-columns: 1fr;
    }
    .article-preview-shell {
        position: static;
    }
}
