/* KHORA Network Analyzer - Dark Theme */

:root {
    --bg-primary: #0a0e17;
    --bg-secondary: #111827;
    --bg-card: #151d2e;
    --bg-card-hover: #1a2540;
    --border: #1e2d4a;
    --border-light: #2a3f5f;
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent-blue: #3b82f6;
    --accent-green: #22c55e;
    --accent-amber: #f59e0b;
    --accent-red: #ef4444;
    --accent-purple: #a855f7;
    --accent-cyan: #06b6d4;
    --kpi-ok: #22c55e;
    --kpi-fail: #ef4444;
    --scrollbar-bg: #1e293b;
    --scrollbar-thumb: #334155;
}

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

body {
    font-family: 'SF Mono', 'Cascadia Code', 'JetBrains Mono', 'Fira Code', monospace;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--scrollbar-bg); }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 3px; }

/* ==================== TOP BAR ==================== */
.top-bar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 16px; height: 48px;
    background: var(--bg-secondary); border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 100;
}
.top-bar-left { display: flex; align-items: center; gap: 24px; }
.logo {
    display: flex; align-items: center; gap: 8px;
    color: var(--accent-blue); font-weight: 700; font-size: 14px; letter-spacing: 0.5px;
}
.nav-tabs { display: flex; gap: 4px; }
.nav-tab {
    padding: 6px 14px; border-radius: 6px; color: var(--text-secondary);
    text-decoration: none; font-size: 12px; font-weight: 500; transition: all 0.15s;
}
.nav-tab:hover { color: var(--text-primary); background: var(--bg-card); }
.nav-tab.active { background: var(--accent-blue); color: white; }
.top-bar-center { display: flex; align-items: center; gap: 12px; }
.search-input {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: 6px;
    padding: 6px 12px; color: var(--text-primary); font-family: inherit; font-size: 12px;
    width: 180px; outline: none; transition: border-color 0.15s;
}
.search-input:focus { border-color: var(--accent-blue); }
.search-input::placeholder { color: var(--text-muted); }
.rssi-filter { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-secondary); }
.rssi-filter select {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: 4px;
    padding: 4px 6px; color: var(--text-primary); font-family: inherit; font-size: 11px; outline: none;
}
.top-bar-right { display: flex; align-items: center; gap: 12px; }
.time-label { font-size: 11px; color: var(--text-muted); }
.time-selector { display: flex; gap: 2px; background: var(--bg-card); border-radius: 6px; padding: 2px; }
.time-btn {
    padding: 4px 10px; border: none; background: transparent; color: var(--text-secondary);
    font-family: inherit; font-size: 11px; font-weight: 500; border-radius: 4px; cursor: pointer; transition: all 0.15s;
}
.time-btn:hover { color: var(--text-primary); }
.time-btn.active { background: var(--accent-blue); color: white; }
.filter-buttons { display: flex; gap: 4px; }
.filter-btn {
    padding: 4px 10px; border: 1px solid var(--border); background: transparent;
    color: var(--text-secondary); font-family: inherit; font-size: 11px; border-radius: 4px; cursor: pointer; transition: all 0.15s;
}
.filter-btn:hover { border-color: var(--accent-blue); color: var(--text-primary); }
.filter-btn.active { background: var(--accent-blue); color: white; border-color: var(--accent-blue); }

/* Language Switcher */
.lang-switch {
    display: flex; align-items: center; justify-content: center;
    width: 32px; height: 26px;
    border: 1px solid var(--border); border-radius: 4px;
    background: var(--bg-card); color: var(--text-secondary);
    font-family: inherit; font-size: 10px; font-weight: 700;
    letter-spacing: 0.5px; cursor: pointer; transition: all 0.15s;
}
.lang-switch:hover { border-color: var(--accent-blue); color: var(--accent-blue); background: rgba(59,130,246,0.1); }

.status-dot {
    width: 10px; height: 10px; border-radius: 50%;
    background: var(--accent-red); transition: background 0.3s;
}
.status-dot.connected { background: var(--accent-green); }

/* ==================== GATEWAY TABS ==================== */
.gateway-tabs {
    display: flex; gap: 4px; padding: 8px 16px;
    background: var(--bg-secondary); border-bottom: 1px solid var(--border);
    overflow-x: auto; white-space: nowrap;
}
.gw-tab {
    padding: 5px 12px; border: 1px solid var(--border); background: transparent;
    color: var(--text-secondary); font-family: inherit; font-size: 11px;
    border-radius: 4px; cursor: pointer; transition: all 0.15s; flex-shrink: 0;
}
.gw-tab:hover { border-color: var(--accent-blue); color: var(--text-primary); }
.gw-tab.active { background: var(--accent-blue); color: white; border-color: var(--accent-blue); }

/* ==================== DASHBOARD ==================== */
.dashboard { padding: 16px; max-width: 1600px; margin: 0 auto; }

/* ==================== KPI CARDS ==================== */
.kpi-row { display: grid; grid-template-columns: repeat(8, 1fr); gap: 10px; margin-bottom: 16px; }
.kpi-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 8px; padding: 14px 16px; transition: border-color 0.15s;
}
.kpi-card:hover { border-color: var(--border-light); }
.kpi-label {
    font-size: 11px; color: var(--text-muted); margin-bottom: 6px;
    text-transform: uppercase; letter-spacing: 0.3px;
}
.kpi-value { font-size: 22px; font-weight: 700; color: var(--text-primary); line-height: 1; }
.kpi-ok { color: var(--kpi-ok); }
.kpi-fail { color: var(--kpi-fail); }

/* ==================== CHART CARDS ==================== */
.charts-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.charts-row-4 { grid-template-columns: repeat(4, 1fr); }
.chart-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 8px; padding: 16px;
}
.chart-card h3 { font-size: 13px; font-weight: 600; color: var(--text-secondary); margin-bottom: 12px; }
.chart-wide { grid-column: span 1; }
.chart-medium { grid-column: span 1; }
.chart-container { position: relative; height: 240px; }
.chart-donut-container { display: flex; align-items: center; justify-content: center; }

/* ==================== JOINS LIST ==================== */
.joins-list { height: 240px; overflow-y: auto; font-size: 11px; }
.join-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 6px 0; border-bottom: 1px solid var(--border);
}
.join-eui { color: var(--accent-cyan); font-weight: 500; }
.join-time { color: var(--text-muted); font-size: 10px; }
.no-data {
    display: flex; align-items: center; justify-content: center;
    height: 100%; color: var(--text-muted); font-size: 12px;
}

/* ==================== DEVICES TABLE ==================== */
.devices-section {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 8px; padding: 16px;
}
.devices-section h3 { font-size: 13px; font-weight: 600; color: var(--text-secondary); margin-bottom: 12px; }
.devices-table-wrapper { overflow-x: auto; max-height: 400px; overflow-y: auto; }
.devices-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.devices-table th {
    position: sticky; top: 0; background: var(--bg-card); text-align: left;
    padding: 8px 10px; color: var(--text-muted); font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.3px; font-size: 10px;
    border-bottom: 1px solid var(--border); z-index: 1;
}
.devices-table td {
    padding: 7px 10px; border-bottom: 1px solid var(--border); color: var(--text-secondary);
}
.devices-table tr:hover td { background: var(--bg-card-hover); color: var(--text-primary); }
.devices-table tr { cursor: pointer; }
.dev-addr { color: var(--accent-cyan); font-weight: 600; }
.operator-badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; }
.operator-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.sf-badge {
    display: inline-block; padding: 2px 6px; border-radius: 3px;
    font-size: 10px; font-weight: 600; background: var(--bg-secondary); color: var(--text-primary);
}
.rssi-bar { display: flex; align-items: center; gap: 6px; }
.rssi-indicator { width: 40px; height: 4px; border-radius: 2px; background: var(--bg-secondary); overflow: hidden; }
.rssi-fill { height: 100%; border-radius: 2px; transition: width 0.3s; }

/* ==================== MODAL ==================== */
.modal-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.7); z-index: 200;
    justify-content: center; align-items: center; padding: 24px;
}
.modal-overlay.open { display: flex; }
.modal-content {
    background: var(--bg-secondary); border: 1px solid var(--border);
    border-radius: 12px; width: 100%; max-width: 1000px; max-height: 90vh; overflow-y: auto;
}
.modal-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 16px; color: var(--text-primary); }
.modal-close {
    background: none; border: none; color: var(--text-muted);
    font-size: 24px; cursor: pointer; line-height: 1;
}
.modal-close:hover { color: var(--text-primary); }
.modal-body { padding: 20px; }
.device-profile { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.profile-stat { background: var(--bg-card); border-radius: 6px; padding: 10px 14px; }
.profile-stat .label { font-size: 10px; color: var(--text-muted); text-transform: uppercase; }
.profile-stat .value { font-size: 18px; font-weight: 700; margin-top: 4px; }
.device-charts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ==================== RESPONSIVE ==================== */
@media (max-width: 1200px) {
    .kpi-row { grid-template-columns: repeat(4, 1fr); }
    .charts-row-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
    .kpi-row { grid-template-columns: repeat(2, 1fr); }
    .charts-row { grid-template-columns: 1fr; }
    .charts-row-4 { grid-template-columns: 1fr; }
    .top-bar-center { display: none; }
    .device-charts { grid-template-columns: 1fr; }
    .device-profile { grid-template-columns: repeat(2, 1fr); }
}
