/* Karbon Studio — Dark theme */
:root {
    --bg-primary: #0f1117;
    --bg-secondary: #161921;
    --bg-tertiary: #1c1f2e;
    --bg-hover: #252838;
    --bg-active: #2d3148;
    --border: #2a2d3e;
    --border-subtle: #1e2130;
    --text-primary: #e5e7eb;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --accent-bg: rgba(99, 102, 241, 0.1);
    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.1);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.1);
    --error: #ef4444;
    --error-bg: rgba(239, 68, 68, 0.1);
    --info: #3b82f6;
    --info-bg: rgba(59, 130, 246, 0.1);
    --font-mono: 'JetBrains Mono', 'Fira Code', 'SF Mono', 'Cascadia Code', monospace;
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    --radius: 8px;
    --radius-sm: 6px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}

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

html, body {
    height: 100%;
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
}

/* Topbar */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 52px;
    padding: 0 20px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    z-index: 10;
}

.topbar-left, .topbar-right { display: flex; align-items: center; gap: 16px; }

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 15px;
    letter-spacing: -0.01em;
}

.logo-accent { color: var(--accent); font-weight: 700; }

.connection-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-muted);
    padding: 4px 10px;
    border-radius: 20px;
    background: var(--bg-tertiary);
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--warning);
    transition: background 0.3s;
}

.connection-status.connected .status-dot { background: var(--success); }
.connection-status.disconnected .status-dot { background: var(--error); }

.uptime { font-size: 12px; color: var(--text-muted); font-family: var(--font-mono); }

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: var(--font-sans);
    cursor: pointer;
    transition: all 0.15s;
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

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

/* Stats bar */
.stats-bar {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 12px;
    padding: 16px 20px;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border);
}

.stat-card {
    padding: 14px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: border-color 0.2s;
}

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

.stat-value {
    font-size: 22px;
    font-weight: 700;
    font-family: var(--font-mono);
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.stat-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 2px;
    padding: 0 20px;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border);
}

.tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border: none;
    background: none;
    color: var(--text-secondary);
    font-size: 13px;
    font-family: var(--font-sans);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.15s;
    margin-bottom: -1px;
}

.tab:hover { color: var(--text-primary); background: var(--bg-hover); }

.tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.tab-count {
    font-size: 11px;
    font-family: var(--font-mono);
    padding: 1px 7px;
    border-radius: 10px;
    background: var(--bg-tertiary);
    color: var(--text-muted);
}

.tab.active .tab-count {
    background: var(--accent-bg);
    color: var(--accent);
}

/* Content */
.content {
    flex: 1;
    overflow: hidden;
    height: calc(100vh - 52px - 100px - 42px);
}

.panel { display: none; height: 100%; overflow: hidden; flex-direction: column; }
.panel.active { display: flex; }

.panel-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-subtle);
}

.search-input {
    flex: 1;
    padding: 8px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13px;
    font-family: var(--font-sans);
    outline: none;
    transition: border-color 0.2s;
}

.search-input::placeholder { color: var(--text-muted); }
.search-input:focus { border-color: var(--accent); }

.filter-group { display: flex; gap: 4px; }

.filter-btn {
    padding: 5px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 12px;
    font-family: var(--font-mono);
    cursor: pointer;
    transition: all 0.15s;
}

.filter-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.filter-btn.active { background: var(--accent-bg); border-color: var(--accent); color: var(--accent); }

/* Table */
.table-wrapper { flex: 1; overflow-y: auto; position: relative; }

.table-wrapper::-webkit-scrollbar { width: 6px; }
.table-wrapper::-webkit-scrollbar-track { background: transparent; }
.table-wrapper::-webkit-scrollbar-thumb { background: var(--bg-active); border-radius: 3px; }
.table-wrapper::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

.data-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.data-table thead {
    position: sticky;
    top: 0;
    z-index: 2;
}

.data-table th {
    padding: 8px 20px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.data-table td {
    padding: 10px 20px;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.data-table tbody tr {
    cursor: pointer;
    transition: background 0.1s;
}

.data-table tbody tr:hover { background: var(--bg-hover); }

.data-table tbody tr.new-row {
    animation: flashRow 0.6s ease-out;
}

@keyframes flashRow {
    0% { background: var(--accent-bg); }
    100% { background: transparent; }
}

.col-status { width: 72px; }
.col-method { width: 80px; }
.col-path { width: auto; }
.col-duration { width: 100px; text-align: right; }
.col-time { width: 90px; text-align: right; }

/* Status badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    font-family: var(--font-mono);
}

.badge-2xx { background: var(--success-bg); color: var(--success); }
.badge-3xx { background: var(--info-bg); color: var(--info); }
.badge-4xx { background: var(--warning-bg); color: var(--warning); }
.badge-5xx { background: var(--error-bg); color: var(--error); }

.badge-success { background: var(--success-bg); color: var(--success); }
.badge-error { background: var(--error-bg); color: var(--error); }
.badge-running { background: var(--info-bg); color: var(--info); }
.badge-queued { background: var(--bg-tertiary); color: var(--text-muted); }

.method-badge {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 12px;
}

.method-GET { color: var(--success); }
.method-POST { color: var(--info); }
.method-PUT { color: var(--warning); }
.method-PATCH { color: var(--accent); }
.method-DELETE { color: var(--error); }

.duration {
    font-family: var(--font-mono);
    font-size: 12px;
    text-align: right;
}

.duration.slow { color: var(--warning); }
.duration.very-slow { color: var(--error); }

.time-ago {
    font-size: 12px;
    color: var(--text-muted);
    font-family: var(--font-mono);
    text-align: right;
}

/* Empty state */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    color: var(--text-muted);
    gap: 8px;
}

.empty-state p { font-size: 15px; color: var(--text-secondary); }
.empty-state span { font-size: 13px; }

/* Slide-over detail panel */
.slideover {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: none;
}

.slideover.open { display: flex; }

.slideover-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
}

.slideover-panel {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 500px;
    max-width: 90vw;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    animation: slideIn 0.2s ease-out;
}

@keyframes slideIn {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

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

.slideover-header h3 {
    font-size: 15px;
    font-weight: 600;
}

.slideover-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.detail-section { margin-bottom: 24px; }

.detail-section-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 10px;
    font-weight: 600;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 13px;
}

.detail-key { color: var(--text-secondary); }

.detail-value {
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 12px;
    text-align: right;
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.headers-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.header-item {
    display: flex;
    gap: 8px;
    padding: 4px 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    font-size: 12px;
    font-family: var(--font-mono);
}

.header-name { color: var(--accent); flex-shrink: 0; }
.header-value { color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; }

/* Responsive */
@media (max-width: 768px) {
    .stats-bar { grid-template-columns: repeat(3, 1fr); }
    .slideover-panel { width: 100%; }
    .topbar { padding: 0 12px; }
    .panel-toolbar { flex-wrap: wrap; }
}
