@import url('https://fonts.googleapis.com/css2?family=Space+Mono:wght@400;700&family=Syne:wght@400;600;800&display=swap');

/* ══════════════════════════════════════════════════════════════════════════════
   VARIABLES
══════════════════════════════════════════════════════════════════════════════ */
:root {
    --bg: #0d0b14;
    --surface: #13101e;
    --surface2: #1c1730;
    --border: #2e2450;
    --border2: #3d3366;

    --violet: #7c5cbf;
    --purple: #a07ee8;
    --lavender: #c4aaff;
    --mauve: #e0c8ff;
    --pink-mist: #d4a8d8;

    --accent: #b892ff;
    --accent2: #df9fff;
    --accent3: #f0c4ff;

    --text: #e8deff;
    --muted: #8070aa;
    --danger: #e87e9f;
    --warning: #e8c27a;

    --mono: 'Space Mono', monospace;
    --sans: 'Syne', sans-serif;

    --header-h: 52px;
    --proxy-h: 34px;
    --toolbar-h: 46px;
    --statsbar-h: 40px;
}

/* ══════════════════════════════════════════════════════════════════════════════
   RESET
══════════════════════════════════════════════════════════════════════════════ */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    height: 100%;
    overflow: hidden;
}

body {
    height: 100%;
    overflow: hidden;
    background: var(--bg);
    background-image:
        radial-gradient(ellipse 65% 50% at 8% 20%, rgba(124, 92, 191, .18), transparent),
        radial-gradient(ellipse 50% 55% at 82% 72%, rgba(160, 126, 232, .12), transparent),
        radial-gradient(ellipse 40% 40% at 50% 5%, rgba(212, 168, 216, .08), transparent);
    color: var(--text);
    font-family: var(--sans);
    font-size: 14px;
}

/* ══════════════════════════════════════════════════════════════════════════════
   HEADER
══════════════════════════════════════════════════════════════════════════════ */
header {
    height: var(--header-h);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(135deg, rgba(19, 16, 30, .97), rgba(28, 23, 48, .97));
    backdrop-filter: blur(12px);
    position: relative;
    flex-shrink: 0;
    z-index: 10;
}

header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent 0%, var(--violet) 20%, var(--lavender) 50%, var(--pink-mist) 75%, transparent 100%);
    opacity: .7;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-badge {
    background: linear-gradient(135deg, var(--violet), var(--purple));
    color: var(--mauve);
    font-family: var(--mono);
    font-size: 10px;
    font-weight: 700;
    padding: 4px 10px;
    letter-spacing: .15em;
    clip-path: polygon(6px 0%, 100% 0%, calc(100% - 6px) 100%, 0% 100%);
    box-shadow: 0 0 14px rgba(124, 92, 191, .5);
}

.logo-title {
    font-family: var(--mono);
    font-size: 12px;
    color: var(--text);
    letter-spacing: .06em;
}

.header-status {
    display: flex;
    align-items: center;
    gap: 18px;
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent3);
    box-shadow: 0 0 8px var(--accent3);
    animation: pulse 2.4s infinite;
    display: inline-block;
    margin-right: 6px;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
        box-shadow: 0 0 8px var(--accent3);
    }

    50% {
        opacity: .3;
        box-shadow: 0 0 3px var(--accent3);
    }
}

.status-label {
    font-family: var(--mono);
    font-size: 10px;
    color: var(--muted);
}

.btn-refresh {
    background: none;
    border: 1px solid var(--border2);
    color: var(--accent);
    font-family: var(--mono);
    font-size: 10px;
    padding: 6px 16px;
    cursor: pointer;
    letter-spacing: .08em;
    transition: all .2s;
    position: relative;
    overflow: hidden;
}

.btn-refresh::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(124, 92, 191, .18), transparent);
    opacity: 0;
    transition: opacity .2s;
}

.btn-refresh:hover {
    border-color: var(--accent);
    color: var(--mauve);
    box-shadow: 0 0 16px rgba(184, 146, 255, .22);
}

.btn-refresh:hover::before {
    opacity: 1;
}

.btn-refresh:disabled {
    color: var(--muted);
    cursor: not-allowed;
    border-color: var(--border);
    box-shadow: none;
}

/* ══════════════════════════════════════════════════════════════════════════════
   BANDEAU PROXY
══════════════════════════════════════════════════════════════════════════════ */
.proxy-note {
    height: var(--proxy-h);
    padding: 0 20px;
    display: flex;
    align-items: center;
    flex-shrink: 0;
    background: linear-gradient(90deg, rgba(124, 92, 191, .08), rgba(160, 126, 232, .04), transparent);
    border-bottom: 1px solid rgba(124, 92, 191, .2);
    font-family: var(--mono);
    font-size: 10px;
    color: var(--muted);
    letter-spacing: .04em;
}

.proxy-note a {
    color: var(--lavender);
}

/* ══════════════════════════════════════════════════════════════════════════════
   PAGE-WRAPPER
══════════════════════════════════════════════════════════════════════════════ */
.page-wrapper {
    height: calc(100vh - var(--header-h) - var(--proxy-h));
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ══════════════════════════════════════════════════════════════════════════════
   CONTAINER
══════════════════════════════════════════════════════════════════════════════ */
.container {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: 290px 1fr;
    overflow: hidden;
}

/* ══════════════════════════════════════════════════════════════════════════════
   SIDEBAR
══════════════════════════════════════════════════════════════════════════════ */
aside {
    border-right: 1px solid var(--border);
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 22px;
    overflow-y: auto;
    background: linear-gradient(180deg, rgba(19, 16, 30, .7), rgba(13, 11, 20, .95));
    scrollbar-width: thin;
    scrollbar-color: var(--border2) transparent;
}

aside::-webkit-scrollbar {
    width: 3px;
}

aside::-webkit-scrollbar-thumb {
    background: var(--border2);
    border-radius: 2px;
}

.section-label {
    font-family: var(--mono);
    font-size: 9px;
    color: var(--violet);
    letter-spacing: .2em;
    text-transform: uppercase;
    margin-bottom: 10px;
}

.search-wrap {
    position: relative;
}

.search-input {
    width: 100%;
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--text);
    font-family: var(--mono);
    font-size: 12px;
    padding: 9px 12px;
    outline: none;
    transition: border-color .2s, box-shadow .2s;
}

.search-input:focus {
    border-color: var(--violet);
    box-shadow: 0 0 0 3px rgba(124, 92, 191, .15), inset 0 0 10px rgba(124, 92, 191, .05);
}

.search-input::placeholder {
    color: var(--muted);
}

.keyword-group {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.kw-tag {
    font-family: var(--mono);
    font-size: 9px;
    padding: 3px 9px;
    border: 1px solid var(--border);
    color: var(--muted);
    cursor: pointer;
    transition: all .18s;
    user-select: none;
    letter-spacing: .05em;
}

.kw-tag:hover {
    border-color: var(--purple);
    color: var(--lavender);
    box-shadow: 0 0 8px rgba(160, 126, 232, .2);
}

.kw-tag.active {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(184, 146, 255, .1);
}

.kw-tag.noise {
    border-color: var(--border);
    color: #5a4a7a;
}

.kw-tag.noise:hover {
    border-color: var(--danger);
    color: var(--danger);
}

.kw-tag.noise.active {
    border-color: var(--danger);
    color: var(--danger);
    background: rgba(232, 126, 159, .08);
    text-decoration: line-through;
}

.source-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.source-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 6px 8px;
    cursor: pointer;
    transition: background .15s;
    border-radius: 2px;
}

.source-item:hover {
    background: rgba(124, 92, 191, .1);
}

.source-check {
    width: 11px;
    height: 11px;
    border: 1px solid var(--border2);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all .15s;
}

.source-check.checked {
    border-color: var(--accent);
    background: linear-gradient(135deg, var(--violet), var(--accent));
}

.source-check.checked::after {
    content: '';
    width: 5px;
    height: 5px;
    background: #fff;
    clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
}

.source-name {
    font-family: var(--mono);
    font-size: 10px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.source-item:hover .source-name {
    color: var(--lavender);
}

/* ══════════════════════════════════════════════════════════════════════════════
   MAIN
══════════════════════════════════════════════════════════════════════════════ */
main {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

/* ══════════════════════════════════════════════════════════════════════════════
   TOOLBAR — tri + toggle de vue
══════════════════════════════════════════════════════════════════════════════ */
.toolbar {
    height: var(--toolbar-h);
    flex-shrink: 0;
    border-bottom: 1px solid var(--border);
    padding: 0 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(19, 16, 30, .92);
    backdrop-filter: blur(8px);
}

.toolbar-label {
    font-family: var(--mono);
    font-size: 10px;
    color: var(--violet);
    letter-spacing: .14em;
}

/* Séparateur visuel dans la toolbar */
.toolbar-sep {
    width: 1px;
    height: 22px;
    background: var(--border);
    margin: 0 4px;
    flex-shrink: 0;
}

.sort-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--muted);
    font-family: var(--mono);
    font-size: 9px;
    padding: 5px 12px;
    cursor: pointer;
    transition: all .18s;
    letter-spacing: .05em;
}

.sort-btn.active,
.sort-btn:hover {
    border-color: var(--purple);
    color: var(--lavender);
    background: rgba(124, 92, 191, .1);
    box-shadow: 0 0 10px rgba(160, 126, 232, .15);
}

/* ── Boutons de vue (liste / grille) ── */
.view-toggle {
    display: flex;
    gap: 4px;
}

.view-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--muted);
    font-family: var(--mono);
    font-size: 13px;
    line-height: 1;
    width: 30px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all .18s;
    padding: 0;
}

.view-btn svg {
    width: 14px;
    height: 14px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.view-btn.active {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(184, 146, 255, .12);
    box-shadow: 0 0 10px rgba(184, 146, 255, .18);
}

.view-btn:not(.active):hover {
    border-color: var(--border2);
    color: var(--lavender);
}

.count-badge {
    margin-left: auto;
    font-family: var(--mono);
    font-size: 10px;
    color: var(--muted);
}

/* ══════════════════════════════════════════════════════════════════════════════
   FEED — conteneur scrollable
══════════════════════════════════════════════════════════════════════════════ */
#feed {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 18px 22px;
    scrollbar-width: thin;
    scrollbar-color: var(--border2) transparent;
}

#feed::-webkit-scrollbar {
    width: 4px;
}

#feed::-webkit-scrollbar-thumb {
    background: var(--border2);
    border-radius: 2px;
}

/* ══════════════════════════════════════════════════════════════════════════════
   MODE LISTE  (#feed.view-list)  — défaut
   Les cartes s'empilent verticalement, pleine largeur
══════════════════════════════════════════════════════════════════════════════ */
#feed.view-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#feed.view-list .article-card {
    flex-shrink: 0;
}

/* En mode liste : description sur 2 lignes, titre affiché complet */
#feed.view-list .article-desc {
    -webkit-line-clamp: 2;
}

/* ══════════════════════════════════════════════════════════════════════════════
   MODE GRILLE  (#feed.view-grid)  — 3 colonnes carrées
══════════════════════════════════════════════════════════════════════════════ */
#feed.view-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-auto-rows: 220px;
    /* hauteur fixe → effet "carré" */
    gap: 12px;
    align-content: start;
}

#feed.view-grid .article-card {
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

/* En mode grille : titre limité à 3 lignes, description à 2 lignes */
#feed.view-grid .article-title {
    font-size: 13px;
    -webkit-line-clamp: 3;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 6px;
}

#feed.view-grid .article-desc {
    -webkit-line-clamp: 2;
    font-size: 11px;
}

/* En grille : la bande latérale devient une bande supérieure */
#feed.view-grid .article-card::before {
    top: 0;
    left: 0;
    right: 0;
    bottom: auto;
    width: auto;
    height: 3px;
    background: linear-gradient(90deg, var(--violet), var(--pink-mist));
}

/* En grille : hover sans translateX, légère élévation */
#feed.view-grid .article-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 28px rgba(124, 92, 191, .25), 0 2px 12px rgba(0, 0, 0, .5);
}

/* En grille : tags masqués pour économiser la place */
#feed.view-grid .article-tags {
    display: none;
}

/* ══════════════════════════════════════════════════════════════════════════════
   ARTICLE CARD — styles communs aux deux modes
══════════════════════════════════════════════════════════════════════════════ */
.article-card {
    border: 1px solid var(--border);
    background: linear-gradient(135deg, var(--surface) 0%, rgba(28, 23, 48, .75) 100%);
    padding: 16px 18px;
    transition: border-color .22s, box-shadow .22s, transform .18s;
    animation: fadeIn .3s ease;
    position: relative;
    overflow: hidden;
}

.article-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: linear-gradient(180deg, var(--violet), var(--pink-mist));
    opacity: 0;
    transition: opacity .22s;
}

.article-card:hover {
    border-color: var(--violet);
}

.article-card:hover::before {
    opacity: 1;
}

/* Hover en mode liste */
#feed.view-list .article-card:hover {
    box-shadow: 0 0 24px rgba(124, 92, 191, .2), 0 2px 14px rgba(0, 0, 0, .45);
    transform: translateX(2px);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.article-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.article-source {
    font-family: var(--mono);
    font-size: 9px;
    color: var(--purple);
    text-transform: uppercase;
    letter-spacing: .1em;
}

.article-date {
    font-family: var(--mono);
    font-size: 9px;
    color: var(--muted);
}

.article-tags {
    display: flex;
    gap: 5px;
    margin-left: auto;
    flex-wrap: wrap;
}

.match-tag {
    font-family: var(--mono);
    font-size: 8px;
    padding: 2px 7px;
    background: rgba(184, 146, 255, .1);
    color: var(--lavender);
    border: 1px solid rgba(184, 146, 255, .3);
    letter-spacing: .05em;
}

.security-tag {
    background: rgba(232, 126, 159, .1);
    color: var(--danger);
    border: 1px solid rgba(232, 126, 159, .3);
}

.article-title {
    font-family: var(--sans);
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.45;
    margin-bottom: 8px;
}

.article-title a {
    color: inherit;
    text-decoration: none;
    transition: color .15s;
}

.article-title a:hover {
    color: var(--lavender);
}

.article-desc {
    font-size: 12px;
    color: var(--muted);
    line-height: 1.65;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.article-desc mark {
    background: rgba(184, 146, 255, .18);
    color: var(--lavender);
    padding: 0 2px;
    border-radius: 2px;
}

/* ══════════════════════════════════════════════════════════════════════════════
   STATS BAR
══════════════════════════════════════════════════════════════════════════════ */
.stats-bar {
    height: var(--statsbar-h);
    flex-shrink: 0;
    border-top: 1px solid var(--border);
    padding: 0 22px;
    display: flex;
    align-items: center;
    gap: 28px;
    background: linear-gradient(90deg, rgba(19, 16, 30, .98), rgba(28, 23, 48, .98));
    font-family: var(--mono);
    font-size: 10px;
    color: var(--muted);
    letter-spacing: .05em;
    position: relative;
}

.stats-bar::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(124, 92, 191, .4) 30%, rgba(184, 146, 255, .6) 50%, rgba(124, 92, 191, .4) 70%, transparent);
}

.stat {
    display: flex;
    gap: 6px;
    align-items: center;
}

.stat-val {
    color: var(--accent);
    font-weight: 700;
    text-shadow: 0 0 10px rgba(184, 146, 255, .4);
}

/* ══════════════════════════════════════════════════════════════════════════════
   ÉTATS
══════════════════════════════════════════════════════════════════════════════ */
.state-msg {
    padding: 60px 20px;
    text-align: center;
    font-family: var(--mono);
    font-size: 12px;
    color: var(--muted);
    grid-column: 1 / -1;
    /* occupe toutes les colonnes en mode grille aussi */
}

.state-msg .icon {
    font-size: 36px;
    margin-bottom: 14px;
    display: block;
    filter: drop-shadow(0 0 12px rgba(184, 146, 255, .4));
}

.loader {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid var(--border2);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .9s linear infinite;
    box-shadow: 0 0 12px rgba(184, 146, 255, .3);
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.source-error {
    font-family: var(--mono);
    font-size: 10px;
    color: var(--danger);
    padding: 8px 12px;
    border: 1px solid rgba(232, 126, 159, .2);
    background: rgba(232, 126, 159, .04);
}