/* === CSS Variables === */
:root {
    --bg-primary: #0d1117;
    --bg-surface: #161b22;
    --bg-card: #1c2333;
    --bg-hover: #21283b;
    --bg-input: #0d1117;
    --border: #30363d;
    --border-light: #21283b;
    --accent: #00b4d8;
    --accent-hover: #0096c7;
    --green: #39d353;
    --red: #f85149;
    --orange: #f0883e;
    --amber: #d29922;
    --yellow: #e3b341;
    --purple: #bc8cff;
    --text-primary: #ffffff;
    --text-secondary: #e0e0e0;
    --text-muted: #c0c0c0;
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
    --sidebar-width: 280px;
    --header-height: 64px;
    --radius: 8px;
    --radius-sm: 4px;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

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

html {
    font-size: 14px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
}

/* === Scrollbar === */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* === Sidebar === */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.logo {
    font-family: var(--font-mono);
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--accent);
    display: flex;
    align-items: center;
    gap: 8px;
}
.logo span {
    background: linear-gradient(135deg, var(--accent), var(--green));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sidebar-section {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-light);
}
.sidebar-section h3 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Category nav */
.category-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.cat-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.15s;
    text-align: left;
}
.cat-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}
.cat-btn.active {
    background: var(--bg-hover);
    color: var(--accent);
    font-weight: 500;
}
.cat-icon {
    font-size: 1rem;
    width: 20px;
    text-align: center;
}
.cat-count {
    margin-left: auto;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--bg-primary);
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 24px;
    text-align: center;
}

/* Toggle filter */
.toggle-filter {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
}
.toggle-filter input {
    display: none;
}
.toggle-slider {
    width: 36px;
    height: 20px;
    background: var(--border);
    border-radius: 10px;
    position: relative;
    transition: background 0.2s;
    flex-shrink: 0;
}
.toggle-slider::after {
    content: '';
    width: 16px;
    height: 16px;
    background: var(--text-muted);
    border-radius: 50%;
    position: absolute;
    top: 2px;
    left: 2px;
    transition: all 0.2s;
}
.toggle-filter input:checked + .toggle-slider {
    background: var(--accent);
}
.toggle-filter input:checked + .toggle-slider::after {
    transform: translateX(16px);
    background: #fff;
}

/* Source list */
.source-list {
    max-height: 200px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.source-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
}
.source-item:hover {
    background: var(--bg-hover);
}
.source-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}
.source-dot.healthy { background: var(--green); }
.source-dot.warning { background: var(--amber); }
.source-dot.error { background: var(--red); }
.source-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.source-count-badge {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* Sidebar footer */
.sidebar-footer {
    padding: 16px 20px;
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Buttons */
.btn-action {
    padding: 8px 12px;
    background: var(--bg-hover);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.15s;
    text-align: center;
}
.btn-action:hover {
    background: var(--bg-card);
    color: var(--text-primary);
    border-color: var(--accent);
}
.btn-sm {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 2px 4px;
}
.btn-primary {
    padding: 10px 16px;
    background: var(--accent);
    color: #000;
    border: none;
    border-radius: var(--radius-sm);
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
.btn-primary:hover {
    background: var(--accent-hover);
}

/* Sidebar toggle (mobile) */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 14px;
    left: 14px;
    z-index: 200;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    width: 36px;
    height: 36px;
    cursor: pointer;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
}
.sidebar-toggle span {
    display: block;
    width: 18px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 1px;
    transition: all 0.2s;
}
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 90;
}

/* === Main === */
.main {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header */
.header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    padding: 12px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    height: var(--header-height);
}
.search-container {
    flex: 1;
    max-width: 400px;
}
.search-input {
    width: 100%;
    padding: 8px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    outline: none;
    transition: border-color 0.15s;
}
.search-input:focus {
    border-color: var(--accent);
}
.search-input::placeholder {
    color: var(--text-muted);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-left: auto;
}
.stats-bar {
    display: flex;
    gap: 8px;
}
.stat-chip {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
    padding: 4px 8px;
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
}
.refresh-info {
    display: flex;
    align-items: center;
    gap: 8px;
}
.last-updated {
    font-size: 0.75rem;
    color: var(--text-muted);
}
.btn-refresh {
    width: 32px;
    height: 32px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--accent);
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.btn-refresh:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
}
.btn-refresh.spinning {
    animation: spin 1s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

.mono { font-family: var(--font-mono); }

/* === Article Grid === */
.article-grid {
    padding: 24px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    flex: 1;
}

/* Article Card */
.article-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: all 0.15s;
    cursor: default;
}
.article-card:hover {
    border-color: var(--border);
    box-shadow: var(--shadow);
    transform: translateY(-1px);
}

.card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
}
.source-favicon {
    width: 16px;
    height: 16px;
    border-radius: 2px;
    background: var(--bg-hover);
    flex-shrink: 0;
}
.card-source-name {
    font-family: var(--font-mono);
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.card-time {
    font-family: var(--font-mono);
    color: var(--text-muted);
    margin-left: auto;
    white-space: nowrap;
}
.card-category {
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}
.cat-news { background: #1f3a5f; color: #58a6ff; }
.cat-cve { background: #3d1f1f; color: #f85149; }
.cat-redteam { background: #3d2e1f; color: #f0883e; }
.cat-threat-intel { background: #2e1f3d; color: #bc8cff; }
.cat-government { background: #1f3d2e; color: #56d364; }
.cat-research { background: #1f3d3d; color: #39d353; }

.card-title {
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.card-title a {
    color: var(--text-primary);
    text-decoration: none;
}
.card-title a:hover {
    color: var(--accent);
}

.card-description {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Severity badge */
.severity-badge {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 3px;
    display: inline-block;
    width: fit-content;
}
.severity-CRITICAL { background: #7d1a1a; color: #ff6b6b; }
.severity-HIGH { background: #6b3a1a; color: #f0883e; }
.severity-MEDIUM { background: #5a4b1a; color: #d29922; }
.severity-LOW { background: #1a3d5a; color: #58a6ff; }
.severity-INFO { background: #1a3d2e; color: #56d364; }

/* CVE IDs */
.cve-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}
.cve-tag {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--amber);
    background: rgba(210, 153, 34, 0.15);
    padding: 2px 6px;
    border-radius: 3px;
}

/* PoC badges */
.poc-badges {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    overflow-x: auto;
}
.poc-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 10px;
    text-decoration: none;
    white-space: nowrap;
    transition: filter 0.15s;
}
.poc-badge:hover {
    filter: brightness(1.2);
}
.poc-github {
    background: #7d1a1a;
    color: #ff6b6b;
}
.poc-exploitdb {
    background: #6b3a1a;
    color: #f0883e;
}
.poc-kev {
    background: #5a4b1a;
    color: #d29922;
}
.poc-kev-ransomware {
    background: #7d1a1a;
    color: #ff4444;
}

.card-footer {
    margin-top: auto;
    display: flex;
    align-items: center;
    justify-content: flex-end;
}
.read-more {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--accent);
    text-decoration: none;
    transition: color 0.15s;
}
.read-more:hover {
    color: var(--accent-hover);
}

/* === Skeleton Loading === */
.skeleton-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.skeleton {
    background: linear-gradient(90deg, var(--bg-hover) 25%, var(--bg-card) 50%, var(--bg-hover) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}
.skeleton-line { height: 12px; }
.skeleton-line-short { height: 12px; width: 60%; }
.skeleton-title { height: 18px; width: 80%; }
.skeleton-badge { height: 20px; width: 60px; }
@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* === Empty State === */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 24px;
    text-align: center;
    flex: 1;
}
.empty-icon {
    font-size: 4rem;
    margin-bottom: 16px;
}
.empty-state h3 {
    color: var(--text-secondary);
    margin-bottom: 8px;
}
.empty-state p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* === Pagination === */
.pagination {
    padding: 20px 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
}
.btn-page {
    padding: 8px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.15s;
}
.btn-page:hover:not(:disabled) {
    background: var(--bg-hover);
    border-color: var(--accent);
    color: var(--accent);
}
.btn-page:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.page-info {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* === Loading overlay === */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(13, 17, 23, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* === Modal === */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}
.modal-content {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.modal-header h2 {
    font-size: 1.1rem;
    color: var(--accent);
}
.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
}
.modal-close:hover {
    color: var(--text-primary);
}
.modal-body {
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.input {
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.85rem;
    outline: none;
    width: 100%;
}
.input:focus {
    border-color: var(--accent);
}
.add-source-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.add-source-form h3 {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

/* Source table */
.source-table-container {
    overflow-x: auto;
}
.source-table-container h3 {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}
.source-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}
.source-table th {
    text-align: left;
    padding: 8px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    font-family: var(--font-mono);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.source-table td {
    padding: 6px 8px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-secondary);
}
.source-table tr:hover td {
    background: var(--bg-hover);
}
.source-enabled-toggle {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--accent);
}
.btn-delete {
    padding: 4px 8px;
    background: transparent;
    border: 1px solid var(--red);
    border-radius: var(--radius-sm);
    color: var(--red);
    font-size: 0.7rem;
    cursor: pointer;
}
.btn-delete:hover {
    background: rgba(248, 81, 73, 0.15);
}

/* Discover */
.discover-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 40px;
    color: var(--text-muted);
}
.discover-results {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.discover-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
}
.discover-item-url {
    flex: 1;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-secondary);
    word-break: break-all;
}
.btn-add-discover {
    padding: 4px 10px;
    background: var(--accent);
    color: #000;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}

/* === Toast === */
#toast-container {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.toast {
    padding: 12px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.85rem;
    box-shadow: var(--shadow);
    animation: slideIn 0.3s ease;
    max-width: 350px;
}
.toast.toast-success { border-left-color: var(--green); }
.toast.toast-error { border-left-color: var(--red); }
.toast.toast-warning { border-left-color: var(--amber); }
@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* === Hidden === */
.hidden { display: none !important; }

/* === Responsive === */
@media (max-width: 1200px) {
    .article-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .sidebar-toggle {
        display: flex;
    }
    .sidebar-overlay.active {
        display: block;
    }
    .main {
        margin-left: 0;
    }
    .article-grid {
        grid-template-columns: 1fr;
        padding: 16px;
    }
    .header {
        padding: 12px 16px;
        padding-left: 56px;
        flex-wrap: wrap;
        height: auto;
    }
    .search-container {
        order: 1;
        max-width: 100%;
        flex-basis: 100%;
    }
    .header-actions {
        order: 0;
        width: 100%;
        justify-content: space-between;
        flex-wrap: wrap;
    }
    .stats-bar {
        display: none;
    }
}
