/* sdrtrunk web UI - the desktop application's dark theme (sdrtrunk_dark.css) and main window layout */

:root {
  --base: #2b2b2b;
  --inner: #313335;
  --inner-alt: #353739;
  --control: #3c3f41;
  --control-hover: #4a4d4f;
  --border: #4f5356;
  --border-light: #555a5e;
  --accent: #4a90d9;
  --accent-hover: #5aa0e9;
  --selection: #214283;
  --hover: #3a3d3f;
  --text: #ececec;
  --text-dim: #b0b0b0;
  --text-muted: #888888;
  --link: #6ab0ff;
  --error: #ff6b6b;
  --good: #3ddc84;
  /* Audio panel: an instrument display, as in audio_panel.css */
  --audio-display: #0d1117;
  --audio-panel: #161b22;
  --audio-panel-active: #1b2430;
  --audio-border: #2a313c;
  --audio-text: #e6edf3;
  --audio-text-secondary: #9aa6b4;
  --audio-text-dim: #5f6b78;
  --audio-live: #3ddc84;
  --audio-muted: #ff5c5c;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--base);
  color: var(--text);
  font: 13px/1.35 system-ui, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  overflow: hidden;
}

.hidden { display: none !important; }
.grow { flex: 1; }
.muted { color: var(--text-muted); }
.mono { font-family: ui-monospace, "DejaVu Sans Mono", Menlo, Consolas, monospace; }
.error { color: var(--error); min-height: 1.3em; }
.good { color: var(--good); }
a { color: var(--link); }

/* Controls, like the Modena dark controls */
button, .button, select, input[type="text"], input[type="search"], input[type="number"], input[type="password"],
input[type="color"], textarea {
  font: inherit;
  color: var(--text);
  border-radius: 3px;
}

button, .button {
  background: var(--control);
  border: 1px solid var(--control-hover);
  padding: 3px 10px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

button:hover:not(:disabled), .button:hover { background: var(--accent); border-color: var(--accent-hover); color: #fff; }
button:active:not(:disabled), button.selected { background: var(--selection); border-color: #3672c4; color: #fff; }
button:disabled { opacity: 0.45; cursor: default; }
button.default { background: var(--accent); border-color: var(--accent-hover); color: #fff; }
button.flat { background: transparent; border-color: transparent; }
button.danger:hover:not(:disabled) { background: #b03a3a; border-color: #c94b4b; }

select, input[type="text"], input[type="search"], input[type="number"], input[type="password"], textarea {
  background: var(--inner);
  border: 1px solid var(--border);
  padding: 3px 6px;
}

input[type="color"] { background: var(--inner); border: 1px solid var(--border); padding: 0; width: 44px; height: 24px; }
select { padding: 2px 4px; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 1px solid var(--accent); outline-offset: 0; }
label.check { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
input[type="checkbox"] { accent-color: var(--accent); }

/* Login */
.login { display: flex; align-items: center; justify-content: center; height: 100%; padding: 20px; }
.login-box {
  display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 330px;
  background: var(--control); border: 1px solid var(--border-light); border-radius: 6px; padding: 26px;
}
.login-box h1 { margin: 0 0 6px; font-size: 20px; text-align: center; font-weight: 600; }
.login-icon { width: 56px; height: 56px; align-self: center; }
.login-box input { padding: 6px 8px; }
.login-box button { justify-content: center; padding: 6px; }
.hint { color: var(--text-muted); font-size: 12px; margin: 0; }

/* Main window */
.app { display: flex; flex-direction: column; height: 100%; }

.menu-bar {
  display: flex; align-items: stretch; background: var(--control); border-bottom: 1px solid var(--border);
  position: relative; z-index: 30; min-height: 26px;
}
.menu { position: relative; }
.menu-title { height: 100%; background: transparent; border: none; border-radius: 0; padding: 3px 10px; }
.menu.open .menu-title { background: var(--accent); color: #fff; }
.menu-items {
  display: none; position: absolute; top: 100%; left: 0; min-width: 260px; background: var(--control);
  border: 1px solid var(--border-light); padding: 3px 0; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
}
.menu.open .menu-items { display: block; }
.menu-items button {
  display: flex; width: 100%; background: transparent; border: none; border-radius: 0; padding: 5px 14px 5px 8px;
  text-align: left;
}
.menu-items button:hover:not(:disabled) { background: var(--accent); }
.menu-items hr { border: none; border-top: 1px solid var(--border-light); margin: 3px 0; }
.mi-icon, .mi-check { display: inline-block; width: 20px; text-align: center; color: var(--accent); }
.menu-items button:hover .mi-icon, .menu-items button:hover .mi-check { color: #fff; }
.menu-items button.checked .mi-check::before { content: "\2713"; }
.menu-spacer { flex: 1; }
.runtime-state { display: flex; align-items: center; padding: 0 10px; font-size: 12px; color: var(--text-dim); gap: 6px; }
.runtime-state::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); }
.runtime-state.awake::before { background: var(--good); }
.runtime-state.waking::before, .runtime-state.sleeping::before { background: #e0a030; }
.runtime-state.blocked::before, .runtime-state.offline::before { background: var(--error); }

/* Audio panel */
.audio-view {
  display: flex; align-items: stretch; gap: 10px; background: var(--audio-display); padding: 8px 10px;
  border-bottom: 1px solid var(--audio-border); color: var(--audio-text);
}
.audio-master { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 2px 4px 2px 0; }
.audio-master-title { color: var(--audio-text-secondary); font-size: 11px; font-weight: bold; letter-spacing: 0.06em; }
.audio-icon-button {
  background: var(--audio-panel); border: 1px solid var(--audio-border); border-radius: 6px; padding: 5px 8px;
  color: var(--audio-text); font-size: 15px;
}
.audio-icon-button:hover:not(:disabled) { background: var(--audio-panel-active); border-color: var(--audio-text-dim); }
.audio-icon-button.selected { background: #3a1a1a; border-color: var(--audio-muted); color: var(--audio-muted); }
.audio-volume { width: 70px; accent-color: var(--audio-text); }
.audio-channel {
  flex: 1; display: flex; align-items: stretch; background: var(--audio-panel); border: 1px solid var(--audio-border);
  border-radius: 6px; min-width: 0; overflow: hidden;
}
.audio-channel.active { background: var(--audio-panel-active); }
.audio-accent { width: 4px; background: var(--audio-text-dim); flex: none; }
.audio-channel.active .audio-accent { background: var(--audio-live); }
.audio-icon-pane { width: 54px; display: flex; align-items: center; justify-content: center; flex: none; }
.audio-icon-pane img { max-width: 36px; max-height: 36px; }
.audio-placeholder-icon { font-size: 24px; opacity: 0.35; }
.audio-channel-content { flex: 1; min-width: 0; padding: 4px 8px 5px 2px; }
.audio-header { display: flex; align-items: center; gap: 8px; font-size: 11px; }
.audio-channel-tag {
  color: var(--audio-text-secondary); border: 1px solid var(--audio-border); border-radius: 3px; padding: 0 5px;
  font-weight: bold; letter-spacing: 0.05em;
}
.audio-status { color: var(--audio-text-dim); font-weight: bold; letter-spacing: 0.05em; }
.audio-status.live { color: var(--audio-live); }
.audio-status.muted { color: var(--audio-muted); }
.audio-elapsed { color: var(--audio-text-secondary); margin-left: auto; font-family: ui-monospace, monospace; }
.audio-to { font-size: 18px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.audio-channel:not(.active) .audio-to { color: var(--audio-text-dim); }
.audio-to-detail { color: var(--audio-text-secondary); font-size: 12px; min-height: 1.2em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.audio-detail-row { display: flex; gap: 6px; font-size: 12px; color: var(--audio-text-secondary); min-height: 1.2em; }
.audio-detail { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.audio-detail-icon { color: var(--audio-text-dim); }
.audio-context { font-size: 11px; color: var(--audio-text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.level-meter { width: 8px; margin: 6px 8px; background: #0a0e13; border: 1px solid var(--audio-border); border-radius: 2px; position: relative; flex: none; }
.level-fill { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: linear-gradient(to top, #3ddc84 0%, #3ddc84 70%, #e0c030 85%, #ff5c5c 100%); background-size: 100% 60px; background-position: bottom; transition: height 0.08s linear; }

/* Center: spectrum, divider and tabs */
.main-center { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.main-hidden-bar {
  display: flex; align-items: center; gap: 8px; padding: 4px 8px 4px 10px; background: #282828;
  border-bottom: 1px solid #202020;
}
.main-hidden-bar-icon { color: var(--accent); }
.main-hidden-bar-label { opacity: 0.8; }

.spectrum-panel { display: flex; flex-direction: column; height: 38%; min-height: 80px; background: #000; flex: none; }
.spectrum-controls {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding: 3px 8px; background: var(--control);
  border-bottom: 1px solid var(--border);
}
.spectrum-controls label { display: inline-flex; align-items: center; gap: 5px; }
.wideband-controls { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
.tuner-checks { display: inline-flex; flex-wrap: wrap; gap: 2px 10px; }
.mhz { width: 100px; }
.zoom-buttons { display: inline-flex; gap: 3px; }
.zoom-buttons button { min-width: 28px; justify-content: center; padding: 1px 6px; }
.span-label { color: var(--text-dim); font-size: 12px; margin-left: auto; }
.spectrum-wrap { position: relative; flex: 1; min-height: 0; }
#spectrum { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: crosshair; touch-action: none; }
.spectrum-message {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--text-dim);
  text-align: center; padding: 20px; pointer-events: none;
}
.readout {
  position: absolute; top: 6px; left: 50%; transform: translateX(-50%); background: rgba(43, 43, 43, 0.85);
  border: 1px solid var(--border-light); border-radius: 3px; padding: 1px 8px; font-size: 12px; pointer-events: none;
}

.split-divider { background: var(--border); flex: none; }
.split-divider.horizontal { height: 5px; cursor: ns-resize; }
.split-divider.vertical { width: 5px; cursor: ew-resize; }
.split-divider:hover { background: var(--accent); }

/* Tab panes */
.tab-pane { display: flex; flex-direction: column; min-height: 0; flex: 1; background: var(--base); }
.tab-header { display: flex; gap: 1px; background: var(--base); padding: 3px 3px 0; border-bottom: 1px solid var(--border); flex: none; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.tab {
  background: var(--control); border: 1px solid var(--border); border-bottom: none; border-radius: 4px 4px 0 0;
  color: var(--text-dim); padding: 4px 14px;
}
.tab:hover:not(:disabled) { background: var(--hover); color: var(--text); border-color: var(--border); }
.tab.active { background: var(--base); color: #fff; position: relative; top: 1px; }
.tab-icon { color: var(--accent); }
.tab:hover .tab-icon { color: var(--accent-hover); }
.tab-content { flex: 1; min-height: 0; position: relative; }
.tab-body { position: absolute; inset: 0; display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.tab-pane.inner .tab-header { background: var(--base); }

/* Tables, like the desktop table views */
.table-wrap { flex: 1; min-height: 0; overflow: auto; background: var(--inner); border: 1px solid var(--border); }
table.grid { border-collapse: collapse; width: 100%; font-size: 12px; }
table.grid th {
  position: sticky; top: 0; z-index: 1; background: var(--control); color: var(--text); font-weight: normal;
  border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 3px 6px;
  text-align: center; white-space: nowrap; user-select: none;
}
table.grid td { padding: 2px 6px; border-right: 1px solid var(--border); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 360px; }
table.grid tbody tr:nth-child(odd) { background: var(--inner); }
table.grid tbody tr:nth-child(even) { background: var(--inner-alt); }
table.grid tbody tr:hover { background: var(--hover); }
table.grid tbody tr.selected { background: var(--selection); color: #fff; }
table.grid td.center { text-align: center; }
table.grid td.left { text-align: left; }
table.grid td.wrap { white-space: normal; }
.placeholder { padding: 18px; text-align: center; color: var(--text-dim); }
.state-cell { text-align: center; font-weight: 500; }
.alias-cell { display: inline-flex; align-items: center; gap: 4px; }
.alias-cell img { width: 14px; height: 14px; }
.alias-swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; flex: none; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; padding: 4px; flex: none; }
.toolbar .search { min-width: 180px; }
.segmented { display: inline-flex; }
.segmented button { border-radius: 0; margin-left: -1px; }
.segmented button:first-child { border-radius: 3px 0 0 3px; margin-left: 0; }
.segmented button:last-child { border-radius: 0 3px 3px 0; }

/* Split views */
.vsplit { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.hsplit { display: flex; flex-direction: row; flex: 1; min-height: 0; }
.pane { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.pane.grow { flex: 1 1 0; }

/* Details */
.details-header { display: flex; align-items: center; gap: 6px; padding: 3px 2px; flex: none; }
.details-header .value { flex: 1; color: var(--text); }
.details-text {
  flex: 1; margin: 0; background: var(--inner); border: 1px solid var(--border); padding: 4px 6px; overflow: auto;
  font-family: ui-monospace, "DejaVu Sans Mono", monospace; font-size: 12px; white-space: pre;
}

/* Editors: titled sections of label/control rows */
.editor { flex: 1; min-height: 0; overflow: auto; padding: 6px 10px 10px; }
.editor-buttons { display: flex; gap: 6px; padding: 6px 10px; border-top: 1px solid var(--border); flex: none; background: var(--base); }
.section { border: 1px solid var(--border); margin: 8px 0; }
.section-title { background: var(--control); padding: 3px 8px; font-weight: 600; }
.section-body { padding: 6px 8px; display: grid; grid-template-columns: max-content 1fr; gap: 5px 12px; align-items: center; }
.section-body > label { color: var(--text-dim); justify-self: end; text-align: right; }
.section-body .row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.section-body .full { grid-column: 1 / -1; }
.section-body .help { grid-column: 2; color: var(--text-muted); font-size: 12px; margin-top: -3px; }
.checks { display: flex; flex-wrap: wrap; gap: 3px 14px; }
.list-editor { display: flex; flex-direction: column; gap: 4px; }
.list-editor .list-row { display: flex; gap: 5px; align-items: center; }

/* Toggle switch, like ControlsFX ToggleSwitch */
.switch { position: relative; display: inline-block; width: 34px; height: 18px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; inset: 0; background: var(--control); border: 1px solid var(--border-light); border-radius: 9px; cursor: pointer; }
.switch .slider::before { content: ""; position: absolute; width: 12px; height: 12px; left: 2px; top: 2px; background: var(--text); border-radius: 50%; transition: transform 0.12s; }
.switch input:checked + .slider { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(16px); }
.switch input:disabled + .slider { opacity: 0.5; cursor: wait; }

/* Windows (playlist editor, received calls) */
.window-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.45); z-index: 50; display: flex; align-items: center; justify-content: center; }
.window {
  background: var(--base); border: 1px solid var(--border-light); box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
  display: flex; flex-direction: column; width: min(1280px, 96vw); height: min(860px, 94vh); border-radius: 4px;
}
.window-title {
  display: flex; align-items: center; gap: 8px; padding: 5px 6px 5px 10px; background: var(--control);
  border-bottom: 1px solid var(--border); font-weight: 600; flex: none; border-radius: 4px 4px 0 0;
}
.window-title img { width: 16px; height: 16px; }
.window-title .grow { flex: 1; }
.window-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.dialog { width: min(480px, 94vw); height: auto; max-height: 90vh; }
.dialog .window-body { padding: 12px 14px; gap: 8px; overflow: auto; }
.dialog-buttons { display: flex; justify-content: flex-end; gap: 6px; padding: 8px 12px; border-top: 1px solid var(--border); }

/* Calls playback bar */
.player { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 5px 6px; border-top: 1px solid var(--border); background: var(--control); flex: none; }
.player audio { flex: 1 1 300px; min-width: 220px; height: 32px; }
.now-listening { flex: 0 1 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-dim); }

/* Map */
.map-wrap { position: relative; flex: 1; min-height: 0; overflow: hidden; background: #1b1d1f; cursor: grab; touch-action: none; }
.map-wrap.dragging { cursor: grabbing; }
.map-wrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.map-attribution { position: absolute; right: 0; bottom: 0; background: rgba(43, 43, 43, 0.8); font-size: 11px; padding: 1px 6px; color: var(--text-dim); }
.map-message { position: absolute; left: 50%; top: 12px; transform: translateX(-50%); background: rgba(43, 43, 43, 0.9); border: 1px solid var(--border-light); padding: 3px 10px; border-radius: 3px; }
.map-popup { position: absolute; background: var(--control); border: 1px solid var(--border-light); padding: 6px 8px; font-size: 12px; max-width: 320px; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5); z-index: 5; }

/* Status bar */
.status-bar {
  display: flex; align-items: center; gap: 16px; padding: 2px 10px; background: var(--control);
  border-top: 1px solid var(--border); font-size: 12px; color: var(--text-dim); flex: none; min-height: 22px;
}
.status-item { display: inline-flex; align-items: center; gap: 6px; }
.status-meter { width: 70px; height: 9px; background: var(--inner); border: 1px solid var(--border); position: relative; }
.status-meter > div { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent); }

/* Sleep overlay */
.sleep-overlay { position: fixed; inset: 0; background: rgba(20, 20, 20, 0.72); z-index: 40; display: flex; align-items: center; justify-content: center; }
.sleep-box { background: var(--control); border: 1px solid var(--border-light); padding: 22px 26px; border-radius: 6px; max-width: 440px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--border-light); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.9s linear infinite; }
.sleep-overlay.blocked .spinner { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed; bottom: 34px; left: 50%; transform: translateX(-50%); background: var(--control); color: var(--text);
  border: 1px solid var(--border-light); padding: 6px 14px; border-radius: 4px; z-index: 80; max-width: 80vw;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5); white-space: pre-line;
}
.toast.error { border-color: var(--error); }

@media (max-width: 760px) {
  .audio-view { padding: 5px; gap: 6px; }
  .audio-icon-pane { display: none; }
  .audio-to { font-size: 15px; }
  .spectrum-panel { height: 34% !important; }
  .span-label { margin-left: 0; }
  .wide-only { display: none; }
  .window { width: 100vw; height: 100vh; border-radius: 0; }
  .hsplit { flex-direction: column; }
  .split-divider.vertical { display: none; }
}
.note { padding: 0 6px; }

/* Phones: waterfall, live audio and starting channels only */
.mobile-brand { display: none; }
.app.mobile .menu[data-menu="view"], .app.mobile .menu[data-menu="tuners"], .app.mobile #main-tabs,
.app.mobile #spectrum-divider, .app.mobile #status-bar, .app.mobile #hide-spectrum,
.app.mobile #spectral-hidden-bar, .app.mobile .zoom-buttons { display: none !important; }
.app.mobile #spectrum-panel { display: flex !important; height: 36% !important; min-height: 150px; }
.app.mobile .mobile-brand { display: flex; align-items: center; gap: 6px; padding: 0 8px; font-weight: 600; }
.app.mobile .mobile-brand img { width: 18px; height: 18px; }
.app.mobile .runtime-state { font-size: 11px; }
.app.mobile .audio-view { padding: 5px 6px; gap: 6px; }
.app.mobile .audio-master { flex-direction: row; align-items: center; }
.app.mobile .audio-master-title { display: none; }
.app.mobile .audio-icon-button { font-size: 20px; padding: 8px 12px; }
.app.mobile .audio-volume { width: 64px; }
.app.mobile .spectrum-controls { gap: 4px 8px; }
.app.mobile .span-label { display: none; }
.mobile-channels { flex: 1; min-height: 0; display: flex; flex-direction: column; background: var(--base); }
.mobile-toolbar { display: flex; gap: 8px; align-items: center; padding: 6px; border-bottom: 1px solid var(--border); }
.mobile-toolbar input[type="search"] { flex: 1; min-width: 0; font-size: 15px; padding: 6px 8px; }
.mobile-list { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.mobile-row { display: flex; align-items: center; gap: 10px; padding: 10px 10px; border-bottom: 1px solid var(--border); }
.mobile-row.running { background: var(--inner); }
.mobile-row .info { flex: 1; min-width: 0; }
.mobile-row .name { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mobile-row .sub { font-size: 12px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mobile-row .activity { font-size: 12px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mobile-row .badge { display: inline-block; padding: 0 6px; border-radius: 3px; font-size: 11px; margin-right: 6px; }
.mobile-row .switch { width: 50px; height: 28px; }
.mobile-row .switch .slider { border-radius: 14px; }
.mobile-row .switch .slider::before { width: 22px; height: 22px; }
.mobile-row .switch input:checked + .slider::before { transform: translateX(22px); }
