/* MediaWatch DS – style.css */

:root {
    --color-primary:       #1e40af;
    --color-primary-hover: #1d3a9e;
    --color-primary-light: #3b82f6;
    --color-success:       #16a34a;
    --color-danger:        #dc2626;
    --color-warning:       #d97706;
    --color-warning-bg:    #fef3c7;
    --color-bg:            #f3f4f6;
    --color-card:          #ffffff;
    --color-text:          #111827;
    --color-muted:         #6b7280;
    --color-border:        #e5e7eb;
    --color-new-bg:        #ecfdf5;
    --color-new-border:    #bbf7d0;
    --color-excluded-bg:   #f9fafb;
    --color-excluded-text: #9ca3af;
    --radius:              6px;
    --shadow:              0 1px 3px rgba(0,0,0,.1);
}

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

html { font-size: 15px; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.5;
}

a { color: var(--color-primary-light); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Navigation ── */
.nav {
    background: var(--color-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    height: 52px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 4px rgba(0,0,0,.2);
}

.nav-brand {
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: .02em;
}
.nav-brand:hover { text-decoration: none; }

.nav-links { display: flex; gap: .25rem; }

.nav-link {
    color: rgba(255,255,255,.85);
    padding: .35rem .75rem;
    border-radius: var(--radius);
    font-size: .9rem;
    display: flex;
    align-items: center;
    gap: .4rem;
    transition: background .15s;
}
.nav-link:hover { background: rgba(255,255,255,.15); text-decoration: none; color: #fff; }
.nav-link.active { background: rgba(255,255,255,.2); color: #fff; font-weight: 600; }

.nav-badge {
    background: #ef4444;
    color: #fff;
    font-size: .7rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 10px;
    line-height: 1.4;
}

/* ── Main layout ── */
.main { max-width: 1200px; margin: 0 auto; padding: 1.5rem 1rem 3rem; }

.page-title { font-size: 1.5rem; font-weight: 700; margin-bottom: 1rem; }

.page-header { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; }

.badge-new-count {
    background: var(--color-success);
    color: #fff;
    font-size: .8rem;
    font-weight: 600;
    padding: .2rem .65rem;
    border-radius: 12px;
}

/* ── Filter bar ── */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    align-items: center;
    background: var(--color-card);
    padding: .75rem 1rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 1rem;
}

.filter-select,
.filter-input {
    padding: .4rem .65rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: .875rem;
    background: #fff;
    color: var(--color-text);
}

.filter-select { min-width: 160px; }
.filter-search { min-width: 200px; flex: 1; }
.filter-input:focus, .filter-select:focus { outline: 2px solid var(--color-primary-light); outline-offset: -1px; }

.filter-checkbox { display: flex; align-items: center; gap: .35rem; font-size: .875rem; white-space: nowrap; cursor: pointer; }
.filter-checkbox input { cursor: pointer; }

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .4rem .9rem;
    border: none;
    border-radius: var(--radius);
    font-size: .875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background .15s, opacity .15s;
    white-space: nowrap;
}
.btn:disabled { opacity: .6; cursor: not-allowed; }

.btn-primary   { background: var(--color-primary); color: #fff; }
.btn-primary:hover   { background: var(--color-primary-hover); }
.btn-secondary { background: var(--color-border); color: var(--color-text); }
.btn-secondary:hover { background: #d1d5db; }
.btn-block { width: 100%; justify-content: center; margin-top: .75rem; }

.btn-exclude, .btn-restore {
    padding: .25rem .6rem;
    font-size: .8rem;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 500;
    transition: opacity .15s;
}
.btn-exclude { background: #fee2e2; color: var(--color-danger); }
.btn-exclude:hover { background: #fecaca; }
.btn-restore { background: #dcfce7; color: var(--color-success); }
.btn-restore:hover { background: #bbf7d0; }
.btn-exclude:disabled, .btn-restore:disabled { opacity: .5; cursor: not-allowed; }

.btn-toggle {
    padding: .2rem .6rem;
    font-size: .8rem;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 500;
    transition: opacity .15s;
}
.btn-toggle.active   { background: #dcfce7; color: var(--color-success); }
.btn-toggle.inactive { background: #f3f4f6; color: var(--color-muted); }
.btn-toggle:disabled { opacity: .5; cursor: not-allowed; }
.btn-link-sm { background: none; border: none; cursor: pointer; font-size: .8rem; padding: .1rem .3rem; color: var(--color-primary); text-decoration: underline; }
.btn-link-sm:hover { opacity: .75; }
.btn-link-danger { color: var(--color-danger, #dc2626); }

/* ── Articles table ── */
.table-info { font-size: .875rem; color: var(--color-muted); margin-bottom: .5rem; }
.table-wrap { overflow-x: auto; }

.articles-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--color-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.articles-table th {
    background: #f8fafc;
    font-size: .8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--color-muted);
    padding: .6rem .9rem;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}
.articles-table td {
    padding: .65rem .9rem;
    vertical-align: top;
    border-bottom: 1px solid var(--color-border);
    font-size: .875rem;
}
.articles-table tr:last-child td { border-bottom: none; }
.articles-table tbody tr:hover { background: #f8fafc; }

.row-new td { background: var(--color-new-bg); border-left: 3px solid var(--color-success); }
.row-new:hover td { background: #d1fae5; }
.row-excluded td { background: var(--color-excluded-bg); opacity: .7; }

.col-title { width: 45%; }
.col-source { white-space: nowrap; }
.col-date { white-space: nowrap; font-size: .8rem; color: var(--color-muted); }
.col-action { width: 80px; text-align: right; }

.article-link { color: var(--color-text); font-weight: 500; line-height: 1.4; }
.article-link:hover { color: var(--color-primary-light); }
.article-snippet { font-size: .8rem; color: var(--color-muted); margin-top: .25rem; line-height: 1.4; }

/* ── Badges ── */
.badge-new {
    display: inline-block;
    background: var(--color-success);
    color: #fff;
    font-size: .65rem;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 4px;
    vertical-align: middle;
    margin-right: .35rem;
    letter-spacing: .05em;
}
.badge-keyword {
    display: inline-block;
    background: #dbeafe;
    color: var(--color-primary);
    font-size: .75rem;
    padding: 1px 7px;
    border-radius: 10px;
    font-weight: 500;
}
.badge-excluded {
    display: inline-block;
    background: #f3f4f6;
    color: var(--color-muted);
    font-size: .75rem;
    padding: 1px 7px;
    border-radius: 10px;
}
.badge-active   { color: var(--color-success); font-size: .8rem; font-weight: 600; }
.badge-inactive { color: var(--color-muted);   font-size: .8rem; }

/* ── Pagination ── */
.pagination {
    display: flex;
    align-items: center;
    gap: .3rem;
    justify-content: center;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}
.page-link {
    padding: .35rem .65rem;
    border-radius: var(--radius);
    font-size: .875rem;
    color: var(--color-primary-light);
    background: var(--color-card);
    border: 1px solid var(--color-border);
    transition: background .15s;
}
.page-link:hover { background: #dbeafe; text-decoration: none; }
.page-link.current { background: var(--color-primary); color: #fff; border-color: var(--color-primary); pointer-events: none; }
.page-ellipsis { padding: .35rem .25rem; color: var(--color-muted); }

/* ── KPI cards ── */
.kpi-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }

.kpi-card {
    background: var(--color-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem 1rem;
    text-align: center;
    border-top: 3px solid var(--color-primary-light);
}
.kpi-value { font-size: 2rem; font-weight: 700; color: var(--color-primary); line-height: 1.1; }
.kpi-label { font-size: .8rem; color: var(--color-muted); margin-top: .35rem; }

/* ── Chart ── */
.chart-container {
    background: var(--color-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1rem;
    position: relative;
}
#stats-chart { display: block; width: 100%; }

/* ── Stats tables ── */
.stats-section { margin-bottom: 2rem; }
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; }
@media (max-width: 700px) { .stats-grid { grid-template-columns: 1fr; } }

.section-title { font-size: 1.1rem; font-weight: 600; margin-bottom: .75rem; color: var(--color-text); }

.stats-table { width: 100%; border-collapse: collapse; font-size: .875rem; background: var(--color-card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.stats-table th { background: #f8fafc; padding: .5rem .75rem; text-align: left; font-size: .75rem; color: var(--color-muted); font-weight: 600; text-transform: uppercase; border-bottom: 1px solid var(--color-border); }
.stats-table td { padding: .5rem .75rem; border-bottom: 1px solid var(--color-border); }
.stats-table tr:last-child td { border-bottom: none; }

.progress-cell { width: 120px; }
.progress-bar { height: 8px; background: var(--color-primary-light); border-radius: 4px; min-width: 2px; }

.text-right  { text-align: right; }
.text-danger { color: var(--color-danger); }

.last-fetch-info { font-size: .9rem; color: var(--color-muted); }

/* ── Admin ── */
.admin-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }

.warning-banner {
    background: var(--color-warning-bg);
    border: 1px solid #fcd34d;
    border-left: 4px solid var(--color-warning);
    color: #92400e;
    padding: .75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: .875rem;
}

.admin-section {
    background: var(--color-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.5rem;
}

.admin-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.admin-table th { background: #f8fafc; padding: .5rem .75rem; text-align: left; font-size: .75rem; color: var(--color-muted); font-weight: 600; text-transform: uppercase; border-bottom: 1px solid var(--color-border); }
.admin-table td { padding: .55rem .75rem; border-bottom: 1px solid var(--color-border); vertical-align: middle; }
.admin-table tr:last-child td { border-bottom: none; }

.col-url { max-width: 260px; word-break: break-all; }
.col-error { max-width: 200px; }
.error-text { font-size: .8rem; }
.col-notes { max-width: 300px; font-size: .8rem; color: var(--color-muted); }
.url-link { font-size: .8rem; color: var(--color-muted); }

.fetch-controls { display: flex; align-items: center; gap: .75rem; }
.fetch-result {
    margin-top: .75rem;
    padding: .65rem 1rem;
    border-radius: var(--radius);
    font-size: .875rem;
    font-weight: 500;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #15803d;
}
.fetch-result.error { background: #fef2f2; border-color: #fecaca; color: var(--color-danger); }

.spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid var(--color-border);
    border-top-color: var(--color-primary-light);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.add-form {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    align-items: center;
    margin-top: 1rem;
    padding-top: .75rem;
    border-top: 1px solid var(--color-border);
}
.add-form .form-input { flex: 1; min-width: 140px; }

/* ── Form elements ── */
.form-label { display: block; font-size: .875rem; font-weight: 500; margin-bottom: .35rem; }
.form-input {
    display: block;
    padding: .45rem .75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: .875rem;
    width: 100%;
    background: #fff;
}
.form-input:focus { outline: 2px solid var(--color-primary-light); outline-offset: -1px; }
.form-error { color: var(--color-danger); font-size: .8rem; }

/* ── Login ── */
.login-wrap { display: flex; justify-content: center; margin-top: 4rem; }
.login-form { background: var(--color-card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 2rem; width: 100%; max-width: 360px; }
.login-title { font-size: 1.25rem; font-weight: 700; margin-bottom: 1.25rem; }

/* ── Alerts ── */
.alert { padding: .65rem 1rem; border-radius: var(--radius); font-size: .875rem; margin-bottom: 1rem; }
.alert-danger { background: #fef2f2; border: 1px solid #fecaca; color: var(--color-danger); }

/* ── Footer ── */
.footer { text-align: center; padding: 2rem 1rem; font-size: .8rem; color: var(--color-muted); }

/* ── Utilities ── */
.hidden { display: none !important; }
.empty-state { color: var(--color-muted); font-size: .875rem; padding: .75rem 0; }
