/* ============================================================
   Aquila Optical Power Network — Dark theme styles
   ============================================================ */

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

:root {
    --bg: #0a0a0e;
    --panel-bg: #131318;
    --panel-border: #252530;
    --text: #e0e4e8;
    --text-dim: #7a8090;
    --accent: #68EAD3;
    --accent-light: #C3F5EA;
    --link-active: #68EAD3;
    --link-marginal: #ffaa00;
    --link-broken: #ff3344;
    --sidebar-width: 300px;
    --header-height: 44px;
    --timebar-height: 52px;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--bg);
    color: var(--text);
    font-family: 'Heebo', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 13px;
    line-height: 1.4;
}

/* --- Header ------------------------------------------------ */
#header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--panel-bg);
    border-bottom: 1px solid var(--panel-border);
    display: flex;
    align-items: center;
    padding: 0 12px;
    z-index: 100;
    gap: 12px;
}

#header .logo {
    height: 28px;
    width: 28px;
    flex-shrink: 0;
    filter: invert(1);
}

#header .title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
}

#header .spacer {
    flex: 1;
}

#header button {
    background: transparent;
    border: 1px solid var(--panel-border);
    color: var(--text-dim);
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.15s;
}

#header button:hover {
    color: var(--text);
    border-color: var(--accent);
    background: rgba(104, 234, 211, 0.1);
}

/* --- Layout ------------------------------------------------ */
#app {
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    bottom: var(--timebar-height);
    display: flex;
}

/* --- Sidebar ----------------------------------------------- */
#sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--panel-bg);
    border-right: 1px solid var(--panel-border);
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 50;
}

#sidebar::-webkit-scrollbar {
    width: 5px;
}

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

#sidebar::-webkit-scrollbar-thumb {
    background: var(--panel-border);
    border-radius: 3px;
}

/* --- Panels ------------------------------------------------ */
.panel {
    border-bottom: 1px solid var(--panel-border);
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    cursor: pointer;
    user-select: none;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-dim);
    transition: color 0.15s;
}

.panel-header:hover {
    color: var(--text);
}

.panel-header::after {
    content: '▾';
    font-size: 10px;
    transition: transform 0.2s;
}

.panel.collapsed .panel-header::after {
    transform: rotate(-90deg);
}

.panel-body {
    padding: 4px 12px 12px;
    display: block;
}

.panel.collapsed .panel-body {
    display: none;
}

/* --- Control rows ------------------------------------------ */
.control-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.control-row label {
    flex: 0 0 80px;
    font-size: 11px;
    color: var(--text-dim);
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.control-row input[type="range"] {
    flex: 1;
    min-width: 0;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--panel-border);
    border-radius: 2px;
    outline: none;
}

.control-row input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
}

.control-row input[type="number"],
.control-row input[type="text"],
.control-row select {
    width: 65px;
    padding: 2px 4px;
    background: var(--bg);
    border: 1px solid var(--panel-border);
    color: var(--text);
    border-radius: 3px;
    font-size: 11px;
    text-align: right;
}

.control-row input[type="number"]:focus,
.control-row input[type="text"]:focus,
.control-row select:focus {
    outline: none;
    border-color: var(--accent);
}

.control-row select {
    width: auto;
    min-width: 65px;
    text-align: left;
}

/* --- Toggle switches --------------------------------------- */
.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 0;
}

.toggle-row span {
    font-size: 11px;
    color: var(--text-dim);
}

.toggle-switch {
    position: relative;
    width: 32px;
    height: 18px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-switch .slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--panel-border);
    border-radius: 9px;
    transition: 0.2s;
}

.toggle-switch .slider::before {
    content: '';
    position: absolute;
    height: 14px;
    width: 14px;
    left: 2px;
    bottom: 2px;
    background: var(--text-dim);
    border-radius: 50%;
    transition: 0.2s;
}

.toggle-switch input:checked + .slider {
    background: var(--accent);
}

.toggle-switch input:checked + .slider::before {
    transform: translateX(14px);
    background: var(--text);
}

/* --- Buttons ----------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 5px 10px;
    background: transparent;
    border: 1px solid var(--panel-border);
    color: var(--text-dim);
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    transition: all 0.15s;
    white-space: nowrap;
}

.btn:hover {
    color: var(--text);
    border-color: var(--accent);
    background: rgba(104, 234, 211, 0.1);
}

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.btn-primary:hover {
    background: var(--accent-light);
    border-color: var(--accent-light);
}

.btn-danger {
    border-color: var(--link-broken);
    color: var(--link-broken);
}

.btn-danger:hover {
    background: rgba(255, 51, 68, 0.15);
}

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

.btn-sm {
    padding: 3px 8px;
    font-size: 10px;
}

/* --- Camera preset buttons --------------------------------- */
.camera-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.camera-presets .btn {
    flex: 1;
    min-width: 80px;
    text-align: center;
}

/* --- Viewport ---------------------------------------------- */
#viewport-container {
    flex: 1;
    position: relative;
    overflow: hidden;
}

#viewport {
    display: block;
    width: 100%;
    height: 100%;
}

/* --- Info overlay on viewport ------------------------------ */
.viewport-info {
    position: absolute;
    bottom: 8px;
    left: 8px;
    font-size: 10px;
    color: var(--text-dim);
    pointer-events: none;
    opacity: 0.6;
}

/* --- Time bar ---------------------------------------------- */
#timebar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--timebar-height);
    background: var(--panel-bg);
    border-top: 1px solid var(--panel-border);
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 12px;
    z-index: 100;
}

#timebar .time-controls {
    display: flex;
    align-items: center;
    gap: 4px;
}

#timebar .time-controls button {
    background: transparent;
    border: 1px solid var(--panel-border);
    color: var(--text-dim);
    width: 28px;
    height: 28px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

#timebar .time-controls button:hover,
#timebar .time-controls button.active {
    color: var(--accent);
    border-color: var(--accent);
}

#timebar .time-slider {
    flex: 1;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--panel-border);
    border-radius: 2px;
    outline: none;
}

#timebar .time-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
}

#timebar .speed-buttons {
    display: flex;
    gap: 2px;
}

#timebar .speed-buttons button {
    background: transparent;
    border: 1px solid var(--panel-border);
    color: var(--text-dim);
    padding: 2px 6px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 10px;
    transition: all 0.15s;
}

#timebar .speed-buttons button:hover,
#timebar .speed-buttons button.active {
    color: var(--accent);
    border-color: var(--accent);
}

#timebar .epoch-display {
    font-size: 11px;
    color: var(--text-dim);
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    white-space: nowrap;
    min-width: 175px;
    text-align: right;
}

/* --- Network stats ----------------------------------------- */
.network-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px 8px;
    margin-bottom: 8px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
}

.stat-item .stat-label {
    color: var(--text-dim);
}

.stat-item .stat-value {
    color: var(--text);
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-weight: 600;
}

/* --- Node list --------------------------------------------- */
.node-list {
    max-height: 200px;
    overflow-y: auto;
    margin-top: 4px;
}

.node-list-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 4px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 11px;
    transition: background 0.1s;
}

.node-list-item:hover {
    background: rgba(104, 234, 211, 0.1);
}

.node-list-item.selected {
    background: rgba(104, 234, 211, 0.2);
}

.node-list-item .node-colour-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.node-list-item .node-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.node-list-item .node-type {
    color: var(--text-dim);
    font-size: 10px;
}

.node-list-item .node-uptime {
    font-size: 9px;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    color: var(--link-active);
    flex-shrink: 0;
}

/* --- Link list --------------------------------------------- */
.link-list-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 4px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 11px;
    transition: background 0.1s;
}

.link-list-item:hover {
    background: rgba(104, 234, 211, 0.1);
}

.link-list-item.selected {
    background: rgba(104, 234, 211, 0.2);
}

.link-list-item .link-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.link-list-item .link-names {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.link-list-item .link-names .link-arrow {
    color: var(--text-dim);
    margin: 0 2px;
}

.link-list-item .link-power {
    font-size: 9px;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    color: var(--text-dim);
    flex-shrink: 0;
}

/* --- Link budget table ------------------------------------- */
.budget-table {
    width: 100%;
    font-size: 11px;
    border-collapse: collapse;
}

.budget-table tr {
    border-bottom: 1px solid rgba(42, 42, 62, 0.5);
}

.budget-table td {
    padding: 3px 0;
}

.budget-table td:first-child {
    color: var(--text-dim);
    padding-right: 8px;
}

.budget-table td:last-child {
    text-align: right;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    color: var(--text);
}

.budget-table .budget-result {
    font-weight: 700;
}

.budget-table .budget-positive {
    color: var(--link-active);
}

.budget-table .budget-negative {
    color: var(--link-broken);
}

.budget-table .budget-marginal {
    color: var(--link-marginal);
}

/* --- Legend ------------------------------------------------ */
.legend-items {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: var(--text-dim);
}

.legend-colour {
    width: 16px;
    height: 4px;
    border-radius: 2px;
    flex-shrink: 0;
}

.legend-colour.legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

/* --- Empty state / placeholder text ------------------------ */
.empty-state {
    padding: 12px 0;
    text-align: centre;
    color: var(--text-dim);
    font-size: 11px;
    font-style: italic;
}

/* --- Section title within a panel -------------------------- */
.section-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin: 8px 0 4px;
    padding-bottom: 2px;
    border-bottom: 1px solid var(--panel-border);
}

/* --- View switch button ------------------------------------- */
.view-switch-btn {
    background: var(--accent);
    border: 1px solid var(--accent);
    color: #fff;
    padding: 4px 14px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.15s;
    margin-right: 8px;
}

.view-switch-btn:hover {
    background: var(--accent-light);
    border-color: var(--accent-light);
}

/* --- Dashboard HUD overlay --------------------------------- */
#dashboard-hud {
    position: fixed;
    top: var(--header-height);
    left: 0; right: 0; bottom: 0;
    pointer-events: none;
    z-index: 10;
    font-family: 'Heebo', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

#dashboard-hud #hud-actions,
#dashboard-hud #hud-timebar,
#dashboard-hud .dash-speed-btn,
#dashboard-hud .hud-btn,
#dashboard-hud .hud-stat[data-tooltip] {
    pointer-events: auto;
}

#hud-left,
#hud-right {
    pointer-events: none;
}

#hud-left {
    position: absolute;
    top: 16px;
    left: 20px;
}

.hud-logo-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
}

.hud-logo {
    height: 24px;
    width: 24px;
    filter: invert(1) brightness(0.8);
    opacity: 0.7;
}

.hud-title {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    background: linear-gradient(135deg, #68EAD3, #C3F5EA);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hud-stats {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.hud-stat {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.hud-stat-value {
    font-size: 20px;
    font-weight: 700;
    color: #f0f4f8;
    min-width: 40px;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

.hud-stat-label {
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 1.5px;
    color: #8a96a8;
    text-transform: uppercase;
}

/* Left-side stat value tints for visual variety */
#dash-stat-sources { color: #FFA94D; }
#dash-stat-relays { color: #68C4EA; }
#dash-stat-orbital-customers { color: #C3F5EA; }
#dash-stat-ground-customers { color: #68EAD3; }
#dash-stat-links-active { color: #66D9A0; }

#hud-right {
    position: absolute;
    top: 16px;
    right: 20px;
    text-align: right;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: flex-end;
}

.hud-stat-large .hud-stat-value {
    font-size: 28px;
}

.hud-stat-large .hud-stat-label {
    color: #a0aab8;
}

.hud-accent {
    color: var(--accent-light) !important;
}

/* Semantic HUD value colours — extended brand palette */
.hud-power {
    color: #FFA94D !important; /* warm amber — power/energy feel */
}

.hud-energy {
    color: var(--accent) !important; /* brand aqua */
}

.hud-revenue {
    color: #66D9A0 !important; /* distinct green — financial */
}

.hud-uptime {
    color: #E1F9F1 !important; /* pale aqua — clean/neutral */
}

/* HUD action buttons */
#hud-actions {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(8, 12, 28, 0.85);
    border: 1px solid rgba(104, 234, 211, 0.2);
    border-radius: 8px;
    padding: 6px 12px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.hud-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: rgba(104, 234, 211, 0.08);
    border: 1px solid rgba(104, 234, 211, 0.2);
    color: var(--text);
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.5px;
    transition: all 0.15s;
    white-space: nowrap;
}

.hud-btn:hover {
    background: rgba(104, 234, 211, 0.18);
    border-color: var(--accent);
    color: #fff;
}

.hud-btn-icon {
    font-size: 14px;
}

.hud-btn-accent {
    background: rgba(104, 234, 211, 0.15);
    border-color: var(--accent);
    color: var(--accent-light);
}

.hud-btn-accent:hover {
    background: rgba(104, 234, 211, 0.3);
}

.hud-btn-dim {
    color: var(--text-dim);
    background: transparent;
    border-color: rgba(104, 234, 211, 0.1);
}

.hud-btn-dim:hover {
    color: var(--text);
    border-color: rgba(104, 234, 211, 0.2);
}

.hud-sep {
    width: 1px;
    height: 24px;
    background: rgba(104, 234, 211, 0.2);
    margin: 0 4px;
}

#hud-timebar {
    position: absolute;
    bottom: 72px;
    left: 20px;
    right: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    pointer-events: auto;
}

#hud-timebar #dash-epoch-display {
    font-size: 11px;
    color: var(--text-dim);
    letter-spacing: 1px;
    white-space: nowrap;
    flex-shrink: 0;
}

#hud-timebar .time-slider {
    flex: 1;
    min-width: 0;
    height: 3px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 2px;
    outline: none;
}

#hud-timebar .time-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: rgba(104, 234, 211, 0.5);
    cursor: pointer;
    transition: background 0.15s;
}

#hud-timebar .time-slider::-webkit-slider-thumb:hover {
    background: rgba(104, 234, 211, 0.8);
}

#hud-timebar .time-slider::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: rgba(104, 234, 211, 0.5);
    border: none;
    cursor: pointer;
}

#hud-timebar .time-slider::-moz-range-track {
    height: 3px;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 2px;
}

#hud-speed-inline {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.dash-speed-btn {
    background: transparent;
    border: 1px solid rgba(104, 234, 211, 0.15);
    color: var(--text-dim);
    padding: 3px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-family: inherit;
    font-size: 11px;
    transition: all 0.15s;
}

.dash-speed-btn:hover,
.dash-speed-btn.active {
    color: var(--accent);
    border-color: var(--accent);
}

/* --- Dashboard view: truly full-screen viewport ------------ */
body.dashboard-view #header,
body.dashboard-view #sidebar,
body.dashboard-view #timebar,
body.dashboard-view .viewport-info {
    display: none !important;
}

body.dashboard-view #app {
    top: 0;
    bottom: 0;
}

body.dashboard-view #viewport-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
}

body.dashboard-view #dashboard-hud {
    top: 0;
}

@media (max-width: 800px) {
    #hud-actions {
        flex-wrap: wrap;
        max-width: 90vw;
        justify-content: center;
    }

    .hud-stat-large .hud-stat-value {
        font-size: 22px;
    }
}

/* --- Responsive: hide sidebar on very small screens -------- */
@media (max-width: 700px) {
    #sidebar {
        position: absolute;
        left: -300px;
        transition: left 0.3s;
        z-index: 60;
    }
    #sidebar.open {
        left: 0;
    }
}

/* --- Info Tooltip ------------------------------------------ */
.info-tooltip {
    position: fixed;
    display: none;
    max-width: 320px;
    padding: 8px 12px;
    background: #1e1e32ee;
    color: var(--text);
    font-size: 12px;
    line-height: 1.5;
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
    pointer-events: none;
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.15s ease;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

[data-tooltip] {
    cursor: help;
}

/* --- Loop button active state ------------------------------ */
#time-loop.active {
    color: var(--accent) !important;
    border-color: var(--accent) !important;
}

#dash-btn-loop.active {
    color: var(--accent-light) !important;
    border-color: var(--accent) !important;
    background: rgba(104, 234, 211, 0.15);
}

