/* PubStats Dashboard — Publifye Standard Dark Theme */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
    --bg: #0d1117;
    --bg-surface: #161b22;
    --bg-elevated: #1c2333;
    --bg-hover: #252d3a;
    --bg-input: #0d1117;
    --text: #e6edf3;
    --text-dim: #8b949e;
    --text-ghost: #6e7681;
    --accent: #f0a030;
    --accent-hover: #e09020;
    --accent-glow: rgba(240, 160, 48, 0.15);
    --link: #58a6ff;
    --green: #3fb950;
    --green-dim: rgba(63, 185, 80, 0.15);
    --red: #f85149;
    --red-dim: rgba(248, 81, 73, 0.15);
    --orange: #d29922;
    --blue: #58a6ff;
    --purple: #bc8cff;
    --border: #30363d;
    --border-accent: #f0a030;
    --radius: 0.75rem;
    --radius-sm: 0.5rem;
    --shadow: 0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.4);
    --transition: 150ms ease;
    --content-w: 1280px;
    --gutter: 1rem;
}

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

body {
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
}

/* === HEADER === */
header {
    max-width: var(--content-w);
    width: calc(100% - var(--gutter) * 2);
    margin: 0.75rem auto 0;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-top: 2px solid var(--accent);
    border-radius: var(--radius);
}

.header-inner {
    padding: 0 1.25rem;
    height: 54px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--accent);
    text-decoration: none;
    letter-spacing: -0.02em;
}

.logo:hover { text-shadow: 0 0 20px var(--accent-glow); }

.version {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8125rem;
    color: var(--text-dim);
    background: var(--bg-elevated);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    border: 1px solid var(--border);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.pubhub-link {
    color: var(--text-dim);
    display: flex;
    align-items: center;
    padding: 6px;
    border-radius: 6px;
    transition: all var(--transition);
}
.pubhub-link:hover { color: var(--accent); background: var(--accent-glow); }
.pubhub-link svg { width: 20px; height: 20px; }

/* === CONTROLS BAR === */
.controls-bar {
    position: sticky;
    top: 0;
    z-index: 90;
    max-width: var(--content-w);
    width: calc(100% - var(--gutter) * 2);
    margin: 0.5rem auto 0;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.controls-inner {
    padding: 0 1.25rem;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.controls-left, .controls-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

select, .btn {
    font-family: 'Outfit', sans-serif;
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0.3rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all var(--transition);
    height: 32px;
    line-height: 1;
}

select:hover, .btn:hover {
    background: var(--bg-hover);
    border-color: var(--text-ghost);
}

select:focus, .btn:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

.btn-group {
    display: flex;
    gap: 0;
}

.btn-group .btn {
    border-radius: 0;
    border-right-width: 0;
}

.btn-group .btn:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.btn-group .btn:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; border-right-width: 1px; }

.btn.active {
    background: var(--accent);
    color: #000;
    border-color: var(--accent);
    font-weight: 600;
}

.btn.active + .btn { border-left-color: var(--accent); }

/* === LAYOUT === */
.container {
    max-width: var(--content-w);
    width: calc(100% - var(--gutter) * 2);
    margin: 0 auto;
    padding: 1rem 0 2rem;
}

/* === KPI CARDS === */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.kpi-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
}

.kpi-card:hover {
    border-color: var(--text-ghost);
    box-shadow: var(--shadow);
}

.kpi-card .label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.375rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.kpi-card .value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}

.kpi-card .value.accent { color: var(--accent); }
.kpi-card .value.green { color: var(--green); }
.kpi-card .value.blue { color: var(--blue); }
.kpi-card .sub {
    font-size: 0.8125rem;
    color: var(--text-ghost);
    margin-top: 0.2rem;
    font-family: 'JetBrains Mono', monospace;
}

/* === CHARTS & CARDS === */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    transition: border-color var(--transition);
}

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

.card.full { grid-column: 1 / -1; }

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.875rem;
}

.card-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.card-badge {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    color: var(--text-ghost);
    background: var(--bg-elevated);
    padding: 0.175rem 0.5rem;
    border-radius: 4px;
}

.chart-wrap {
    position: relative;
    height: 240px;
}

.chart-wrap.tall { height: 280px; }

/* === TABLES === */
.stat-table {
    width: 100%;
    border-collapse: collapse;
}

.stat-table tr { transition: background var(--transition); }
.stat-table tr:hover { background: var(--bg-hover); }

.stat-table td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid rgba(48, 54, 61, 0.5);
    font-size: 0.9375rem;
}

.stat-table td:first-child {
    color: var(--text);
    font-weight: 500;
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stat-table td:last-child {
    text-align: right;
    color: var(--text-dim);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.875rem;
    font-weight: 500;
    white-space: nowrap;
}

.stat-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.stat-bar-track {
    flex: 1;
    height: 5px;
    background: var(--bg-elevated);
    border-radius: 3px;
    overflow: hidden;
}

.stat-bar-fill {
    height: 100%;
    border-radius: 3px;
    background: var(--accent);
    transition: width 0.4s ease;
}

.stat-bar-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.875rem;
    color: var(--text-dim);
    min-width: 48px;
    text-align: right;
}

/* === REALTIME DOT === */
.rt-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--green);
    animation: pulse 2s ease-in-out infinite;
    box-shadow: 0 0 6px var(--green);
}

@keyframes pulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 6px var(--green); }
    50% { opacity: 0.5; box-shadow: 0 0 2px var(--green); }
}

/* === EMPTY STATE === */
.empty-state {
    text-align: center;
    color: var(--text-dim);
    padding: 3rem 2rem;
    font-size: 0.9375rem;
}

.empty-state p { margin-top: 0.5rem; color: var(--text-ghost); font-size: 0.875rem; }

/* === TOAST === */
.toast-container {
    position: fixed;
    top: 72px;
    right: 1.5rem;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius-sm);
    padding: 0.625rem 0.875rem;
    font-size: 0.875rem;
    color: var(--text);
    box-shadow: var(--shadow-lg);
    animation: toast-in 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    max-width: 320px;
}

.toast.error { border-left-color: var(--red); }
.toast.success { border-left-color: var(--green); }

@keyframes toast-in {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

/* === RESPONSIVE === */
@media (max-width: 1024px) {
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .grid-3 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
    :root { --gutter: 0.625rem; }
    .kpi-grid { grid-template-columns: 1fr 1fr; }
    .grid-2 { grid-template-columns: 1fr; }
    .grid-3 { grid-template-columns: 1fr; }
    .controls-bar .controls-inner { flex-wrap: wrap; height: auto; padding: 0.5rem 1rem; gap: 0.5rem; }
    .header-inner { padding: 0 1rem; }
}

@media (max-width: 480px) {
    .kpi-grid { grid-template-columns: 1fr; }
    .kpi-card .value { font-size: 1.5rem; }
    .header-left { gap: 0.5rem; }
    .logo { font-size: 1.125rem; }
}
