/* ============================================================
   The Oracle — Dashboard Theme
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-card: #16161f;
    --bg-card-hover: #1c1c28;
    --bg-input: #1a1a26;
    --border: rgba(255, 255, 255, 0.06);
    --border-active: rgba(139, 92, 246, 0.4);
    --text-primary: #f0f0f5;
    --text-secondary: #8888a0;
    --text-muted: #55556a;
    --accent: #8b5cf6;
    --accent-glow: rgba(139, 92, 246, 0.15);
    --accent-bright: #a78bfa;
    --green: #34d399;
    --green-dim: rgba(52, 211, 153, 0.12);
    --red: #f87171;
    --red-dim: rgba(248, 113, 113, 0.12);
    --orange: #fb923c;
    --orange-dim: rgba(251, 146, 60, 0.12);
    --blue: #60a5fa;
    --blue-dim: rgba(96, 165, 250, 0.12);
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* ---- Layout ---- */
.app {
    display: grid;
    grid-template-columns: 280px 1fr;
    grid-template-rows: 64px 1fr;
    height: 100vh;
    overflow: hidden;
}

/* ---- Header ---- */
.header {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    z-index: 100;
}

.header__brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header__logo {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--accent), #c084fc);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    box-shadow: 0 0 20px var(--accent-glow);
}

.header__title {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, var(--text-primary), var(--accent-bright));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.header__subtitle {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    font-weight: 500;
}

.header__status {
    display: flex;
    align-items: center;
    gap: 16px;
}

.status-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: var(--green-dim);
    border-radius: 100px;
    font-size: 12px;
    font-weight: 500;
    color: var(--green);
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--green);
    animation: pulse 2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }
}

/* ---- Sidebar ---- */
.sidebar {
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    padding: 16px 0;
}

.sidebar__section {
    padding: 0 16px;
    margin-bottom: 24px;
}

.sidebar__label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    margin-bottom: 8px;
    padding: 0 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 400;
}

.nav-item:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--accent-glow);
    color: var(--accent-bright);
    font-weight: 500;
}

.nav-item__icon {
    font-size: 16px;
    width: 20px;
    text-align: center;
}

.nav-item__badge {
    margin-left: auto;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 100px;
    background: var(--bg-card);
    color: var(--text-muted);
    font-weight: 500;
    font-family: 'JetBrains Mono', monospace;
}

/* ---- Category Tree ---- */
.cat-tree {
    padding: 0 8px;
}

.cat-node {
    cursor: pointer;
    user-select: none;
}

.cat-node__row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text-secondary);
    transition: var(--transition);
}

.cat-node__row:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.cat-node__row.selected {
    background: var(--accent-glow);
    color: var(--accent-bright);
}

.cat-node__toggle {
    width: 16px;
    font-size: 10px;
    color: var(--text-muted);
    transition: transform var(--transition);
}

.cat-node__toggle.open {
    transform: rotate(90deg);
}

.cat-node__children {
    padding-left: 20px;
}

/* ---- Main Content ---- */
.main {
    overflow-y: auto;
    padding: 24px;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.page-header h1 {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.page-header p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 4px;
}

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

.card:hover {
    border-color: var(--border-active);
}

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

.card__title {
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card__body {
    padding: 20px;
}

/* ---- Stats Grid ---- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-2px);
    border-color: var(--border-active);
    box-shadow: var(--shadow);
}

.stat-card__label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.stat-card__value {
    font-size: 28px;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
    letter-spacing: -1px;
}

.stat-card__delta {
    font-size: 12px;
    margin-top: 4px;
    font-weight: 500;
}

.stat-card__delta--up {
    color: var(--green);
}

.stat-card__delta--down {
    color: var(--red);
}

/* ---- Table ---- */
.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

thead th {
    text-align: left;
    padding: 12px 16px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

tbody tr {
    transition: var(--transition);
}

tbody tr:hover {
    background: var(--bg-card-hover);
}

tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
}

.tag-cell {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 500;
    color: var(--text-primary);
}

.rank-cell {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
    color: var(--accent-bright);
}

.velocity-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 100px;
    font-size: 12px;
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
}

.velocity-badge--up {
    background: var(--green-dim);
    color: var(--green);
}

.velocity-badge--down {
    background: var(--red-dim);
    color: var(--red);
}

.velocity-badge--flat {
    background: var(--bg-input);
    color: var(--text-muted);
}

.category-chip {
    display: inline-block;
    padding: 2px 8px;
    margin: 1px 3px;
    border-radius: 100px;
    font-size: 11px;
    background: var(--blue-dim);
    color: var(--blue);
    font-weight: 500;
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.btn--primary {
    background: var(--accent);
    color: white;
}

.btn--primary:hover {
    background: var(--accent-bright);
    box-shadow: 0 0 20px var(--accent-glow);
}

.btn--secondary {
    background: var(--bg-input);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

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

.btn--sm {
    padding: 5px 10px;
    font-size: 12px;
}

/* ---- Forms ---- */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
    transition: var(--transition);
    outline: none;
}

.form-control:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

textarea.form-control {
    min-height: 100px;
    resize: vertical;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
}

/* ---- Modal / Slide Panel ---- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
}

.modal-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 480px;
    max-width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 16px 64px rgba(0, 0, 0, 0.5);
    transform: translateY(20px);
    transition: transform 0.25s;
}

.modal-overlay.visible .modal {
    transform: translateY(0);
}

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

.modal__title {
    font-size: 16px;
    font-weight: 600;
}

.modal__close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
    transition: var(--transition);
}

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

.modal__body {
    padding: 24px;
}

.modal__footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

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

.empty-state__icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state__title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.empty-state__desc {
    font-size: 13px;
    max-width: 320px;
    margin: 0 auto 20px;
}

/* ---- Toast ---- */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    box-shadow: var(--shadow);
    animation: slideInToast 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
}

.toast--success {
    border-left: 3px solid var(--green);
}

.toast--error {
    border-left: 3px solid var(--red);
}

.toast--info {
    border-left: 3px solid var(--blue);
}

@keyframes slideInToast {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ---- Loading Skeleton ---- */
.skeleton {
    background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-card-hover) 50%, var(--bg-card) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* ---- Report ---- */
.report-content {
    font-size: 14px;
    line-height: 1.8;
    color: var(--text-secondary);
    white-space: pre-wrap;
    font-family: 'Inter', sans-serif;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .app {
        grid-template-columns: 1fr;
    }

    .sidebar {
        display: none;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* ---- Source Badges ---- */
.source-badge {
    display: inline-block;
    padding: 2px 8px;
    margin: 1px 2px;
    border-radius: 100px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.source-badge--blue {
    background: var(--blue-dim);
    color: var(--blue);
}

.source-badge--red {
    background: var(--red-dim);
    color: var(--red);
}

.source-badge--orange {
    background: var(--orange-dim);
    color: var(--orange);
}

.source-badge--green {
    background: var(--green-dim);
    color: var(--green);
}

.source-badge--pink {
    background: rgba(236, 72, 153, 0.12);
    color: #ec4899;
}

.source-badge--purple {
    background: var(--accent-glow);
    color: var(--accent-bright);
}

.source-badge--muted {
    background: var(--bg-input);
    color: var(--text-muted);
}