/* ── WindApp Setup / Onboarding Styles ──────────────────────── */

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

:root {
  --bg: #0f1117;
  --surface: rgba(255, 255, 255, 0.04);
  --surface-hover: rgba(255, 255, 255, 0.07);
  --border: rgba(255, 255, 255, 0.1);
  --border-active: rgba(167, 139, 250, 0.5);
  --text: #e8ecf1;
  --text-dim: #8892a4;
  --accent: #a78bfa;
  --accent-bg: rgba(167, 139, 250, 0.15);
  --danger: #f87171;
  --success: #4ade80;
  --blue: #60a5fa;
  --radius: 12px;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}

.hidden { display: none !important; }

/* ── Step indicator (top bar) ───────────────────────────────── */
#step-indicator {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 16px 20px;
  background: rgba(15, 17, 23, 0.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.step-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  border: 2px solid var(--border);
  color: var(--text-dim);
  transition: all 0.3s;
}

.step-dot.active {
  border-color: var(--accent);
  background: var(--accent-bg);
  color: var(--accent);
}

.step-dot.done {
  border-color: var(--success);
  background: rgba(74, 222, 128, 0.15);
  color: var(--success);
}

.step-line {
  width: 40px;
  height: 2px;
  background: var(--border);
  margin: 0 4px;
}

/* ── Steps ───────────────────────────────────────────────────── */
.step {
  display: none;
  min-height: 100vh;
  padding: 80px 20px 40px;
}

.step.active {
  display: block;
}

.step-content {
  max-width: 480px;
  margin: 0 auto;
}

.step-icon {
  font-size: 2.5rem;
  margin-bottom: 8px;
}

.step h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.step-sub {
  color: var(--text-dim);
  font-size: 0.85rem;
  margin-bottom: 28px;
  line-height: 1.5;
}

/* ── Buttons ──────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary {
  background: rgba(167, 139, 250, 0.7);
  color: #fff;
}
.btn-primary:hover:not(:disabled) {
  background: rgba(167, 139, 250, 0.9);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--surface-hover);
}

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

.btn-large {
  padding: 14px 28px;
  font-size: 0.95rem;
}

.btn-icon {
  font-size: 1.1em;
}

/* ── Form fields ──────────────────────────────────────────────── */
.input-group {
  margin-bottom: 20px;
}

.or-divider {
  text-align: center;
  margin: 18px 0;
  color: var(--text-dim);
  font-size: 0.75rem;
}

.or-divider span {
  padding: 0 12px;
  background: var(--bg);
  position: relative;
}

.or-divider::before {
  content: '';
  position: absolute;
  left: 10%;
  right: 10%;
  top: 50%;
  height: 1px;
  background: var(--border);
}

.or-divider {
  position: relative;
}

.field-row {
  display: flex;
  gap: 12px;
}

.field-row .field {
  flex: 1;
}

.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.field label .optional {
  text-transform: none;
  font-weight: 400;
  color: rgba(136, 146, 164, 0.6);
}

.field input,
.field select {
  width: 100%;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
}

.field input:focus,
.field select:focus {
  border-color: var(--border-active);
}

.field input::placeholder {
  color: rgba(136, 146, 164, 0.5);
}

.manual-inputs {
  margin-top: 8px;
}

/* ── Location search ───────────────────────────────────────── */
.search-wrap {
  margin-bottom: 4px;
}

.search-input-row {
  display: flex;
  gap: 8px;
}

.search-input-row input {
  flex: 1;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
}

.search-input-row input:focus {
  border-color: var(--border-active);
}

.search-input-row input::placeholder {
  color: rgba(136, 146, 164, 0.5);
}

.search-input-row .btn {
  flex-shrink: 0;
  padding: 10px 14px;
}

#search-results {
  margin-top: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(15, 17, 23, 0.95);
  backdrop-filter: blur(8px);
  max-height: 240px;
  overflow-y: auto;
}

.search-result-item {
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}

.search-result-item:last-child {
  border-bottom: none;
}

.search-result-item:hover {
  background: var(--surface-hover);
}

.search-result-name {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text);
  line-height: 1.4;
}

.search-result-meta {
  font-size: 0.68rem;
  color: var(--text-dim);
  margin-top: 2px;
}

.search-no-results {
  padding: 14px;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-dim);
}

/* ── Location map (mini preview) ──────────────────────────────── */
#location-map-wrap {
  margin: 16px 0;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}

#location-map {
  height: 180px;
  width: 100%;
}

#location-readout {
  padding: 8px 12px;
  font-size: 0.75rem;
  color: var(--text-dim);
  background: var(--surface);
}

/* ── Step actions (next/back buttons) ─────────────────────────── */
.step-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 28px;
  gap: 12px;
}

.step-actions .btn-primary {
  margin-left: auto;
}

/* ── DOF Map Picker ────────────────────────────────────────────── */
#dof-map-wrap {
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  margin-bottom: 16px;
  position: relative;
}

#dof-map {
  height: 260px;
  width: 100%;
  cursor: crosshair;
}

#dof-map-hint {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 8px 12px;
  font-size: 0.72rem;
  color: var(--text-dim);
  background: rgba(15, 17, 23, 0.85);
  backdrop-filter: blur(6px);
  text-align: center;
  z-index: 500;
  pointer-events: none;
  transition: opacity 0.3s;
}

#dof-map-hint.picked {
  color: var(--success);
}

.dof-target-icon {
  background: none;
  border: none;
}

.dof-target-ring {
  font-size: 1.5rem;
  text-align: center;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,0.7));
}

.dof-tooltip {
  background: rgba(15, 17, 23, 0.85);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 6px;
  box-shadow: none;
}

.dof-tooltip::before {
  border-bottom-color: rgba(15, 17, 23, 0.85) !important;
}

/* ── DOF Compass ──────────────────────────────────────────────── */
.dof-input-area {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  margin-bottom: 8px;
}

.compass-container {
  flex-shrink: 0;
  width: 200px;
  height: 200px;
}

#compass-svg {
  width: 100%;
  height: 100%;
}

.dof-controls {
  flex: 1;
  padding-top: 16px;
}

.dof-readout {
  font-size: 2rem;
  font-weight: 700;
  color: var(--danger);
  margin: 8px 0 12px;
}

.dof-hint {
  font-size: 0.72rem;
  color: var(--text-dim);
  line-height: 1.5;
  padding: 10px 12px;
  background: var(--surface);
  border-radius: 8px;
  border-left: 3px solid var(--accent);
}

/* ── Station list ─────────────────────────────────────────────── */
#station-list {
  margin: 16px 0;
}

.station-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 10px;
  cursor: pointer;
  transition: all 0.2s;
}

.station-card:hover {
  background: var(--surface-hover);
}

.station-card.selected {
  border-color: var(--accent);
  background: var(--accent-bg);
}

.station-check {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  flex-shrink: 0;
  transition: all 0.2s;
}

.station-card.selected .station-check {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.station-info {
  flex: 1;
  min-width: 0;
}

.station-name {
  font-weight: 600;
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 6px;
}

.source-badge {
  display: inline-block;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  letter-spacing: 0.04em;
  flex-shrink: 0;
  text-transform: uppercase;
}

.badge-wf {
  background: rgba(96, 165, 250, 0.2);
  color: #60a5fa;
  border: 1px solid rgba(96, 165, 250, 0.3);
}

.badge-wu {
  background: rgba(250, 204, 21, 0.15);
  color: #facc15;
  border: 1px solid rgba(250, 204, 21, 0.3);
}

.station-meta {
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-top: 2px;
}

.station-distance {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--blue);
  white-space: nowrap;
}

/* ── Station map ──────────────────────────────────────────────── */
#station-map-wrap {
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  margin-bottom: 16px;
}

#station-map {
  height: 220px;
  width: 100%;
}

/* ── Data sources ─────────────────────────────────────────────── */
.source-options {
  display: Grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.source-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 18px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
}

.source-card:hover {
  background: var(--surface-hover);
}

.source-card.selected {
  border-color: var(--accent);
  background: var(--accent-bg);
}

.source-card input[type="radio"] {
  display: none;
}

.source-icon {
  font-size: 1.6rem;
  margin-bottom: 6px;
}

.source-label {
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.source-desc {
  font-size: 0.65rem;
  color: var(--text-dim);
  line-height: 1.4;
}

/* ── BLE panel ────────────────────────────────────────────────── */
#ble-panel {
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
  margin-bottom: 16px;
}

.ble-status {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-bottom: 12px;
}

/* ── Loading ──────────────────────────────────────────────────── */
.loading-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 40px 20px;
  color: var(--text-dim);
  font-size: 0.85rem;
}

.spinner {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Manual station add ────────────────────────────────────── */
.manual-station-add {
  margin-top: 8px;
}

.manual-status {
  font-size: 0.75rem;
  margin-top: 6px;
  min-height: 1.2em;
}

.manual-status.error { color: var(--danger); }
.manual-status.success { color: var(--success); }

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 500px) {
  #dof-map {
    height: 220px;
  }

  .dof-input-area {
    flex-direction: column;
    align-items: center;
  }

  .compass-container {
    width: 180px;
    height: 180px;
  }

  .source-options {
    grid-template-columns: 1fr;
  }

  .step h1 {
    font-size: 1.25rem;
  }
}

/* ── Saved Profiles Bar ─────────────────────────────────────── */
#saved-profiles-bar {
  max-width: 600px;
  margin: 80px auto 20px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.profiles-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.profiles-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}

.profiles-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.profile-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: border-color 0.2s;
}

.profile-card:hover {
  border-color: var(--border-active);
}

.profile-card-info {
  flex: 1;
  min-width: 0;
}

.profile-card-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-card-detail {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 2px;
}

.profile-card-actions {
  display: flex;
  gap: 6px;
  margin-left: 12px;
  flex-shrink: 0;
}

.btn-small {
  padding: 5px 10px;
  font-size: 0.72rem;
  border-radius: 8px;
}

.btn-danger {
  background: rgba(248, 113, 113, 0.15);
  color: var(--danger);
  border-color: rgba(248, 113, 113, 0.3);
}
.btn-danger:hover {
  background: rgba(248, 113, 113, 0.25);
}

/* ── Profile Save Section (Step 4) ──────────────────────────── */
.profile-save-section {
  margin-top: 24px;
  padding: 16px 20px;
  background: rgba(96, 165, 250, 0.06);
  border: 1px solid rgba(96, 165, 250, 0.2);
  border-radius: var(--radius);
}

.profile-save-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--blue);
  margin-bottom: 4px;
}

.profile-save-desc {
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-bottom: 12px;
}

.profile-name-row {
  display: flex;
  gap: 8px;
}

.profile-name-row .inp {
  flex: 1;
}
