/* Deconfliction Advisory — high-contrast cockpit display */

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

html, body {
  width: 100%;
  height: 100%;
  background: #000;
  color: #fff;
  font-family: -apple-system, "Helvetica Neue", Helvetica, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

/* --- Backend connection indicator --- */

.conn-indicator {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 18px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #888;
}

.conn-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #888;
}

.conn-indicator.connected {
  color: #00cc44;
}

.conn-indicator.connected .conn-dot {
  background: #00cc44;
  box-shadow: 0 0 8px rgba(0, 204, 68, 0.8);
}

.conn-indicator.disconnected {
  color: #ff3b30;
}

.conn-indicator.disconnected .conn-dot {
  background: #ff0000;
  box-shadow: 0 0 8px rgba(255, 0, 0, 0.8);
}

/* --- Views --- */

.view {
  display: none;
  width: 100%;
  height: 100%;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.view.active {
  display: flex;
}

/* --- Setup view --- */

#setup-view {
  gap: 24px;
  text-align: center;
}

#setup-view h1 {
  font-size: 28px;
  font-weight: 700;
}

#setup-view p {
  font-size: 18px;
  color: #aaa;
  max-width: 500px;
  line-height: 1.5;
}

.btn-enable {
  background: #cc0000;
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 22px;
  font-weight: 700;
  padding: 20px 48px;
  cursor: pointer;
  min-height: 80px;
}

.btn-enable:active {
  background: #990000;
}

/* --- Idle view --- */

#idle-view {
  gap: 16px;
  text-align: center;
}

#idle-view h2 {
  font-size: 24px;
  font-weight: 600;
}

#idle-view .status-line {
  font-size: 18px;
  color: #aaa;
}

#idle-view .debug-section {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
  right: calc(env(safe-area-inset-right, 0px) + 16px);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#dev-tools {
  display: none;
  flex-direction: column;
  gap: 12px;
}

#dev-tools.open {
  display: flex;
}

.btn-debug {
  background: #333;
  color: #fff;
  border: 1px solid #555;
  border-radius: 8px;
  font-size: 16px;
  padding: 14px 32px;
  cursor: pointer;
  min-height: 60px;
}

.btn-debug:active {
  background: #555;
}

#btn-show-url {
  position: fixed;
  bottom: 16px;
  right: 16px;
  font-size: 12px;
  padding: 8px 14px;
  min-height: unset;
  opacity: 0.5;
  z-index: 999;
}

.ff-url-display {
  display: block;
  max-width: 90%;
  margin: 4px auto 0;
  padding: 10px 14px;
  background: #111;
  border: 1px solid #333;
  border-radius: 8px;
  color: #4da3ff;
  font-family: monospace;
  font-size: 13px;
  line-height: 1.4;
  word-break: break-all;
  text-align: left;
}

.ff-url-display.ff-url-missing {
  color: #ffb300;
  border-color: #5a4500;
}

/* --- Monitor -> Planner nav button --- */

.btn-nav {
  background: #1a3a5a;
  color: #fff;
  border: 1px solid #2f5f8f;
  border-radius: 12px;
  font-size: 20px;
  font-weight: 700;
  padding: 18px 36px;
  margin-top: 8px;
  cursor: pointer;
  min-height: 64px;
}

.btn-nav:active {
  background: #2f5f8f;
}

/* --- Mission planner view --- */
/* Override the centered .view layout: the planner is a full-height stack
   with the map taking all the space between the top bar and the panel. */

#planner-view {
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  padding: 0;
  padding-top: env(safe-area-inset-top, 0px);
}

.planner-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: #111;
  border-bottom: 1px solid #333;
}

.planner-bar .btn-debug {
  font-size: 15px;
  padding: 10px 18px;
  min-height: 48px;
}

.planner-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 1px;
}

#map {
  flex: 1 1 auto;
  width: 100%;
  min-height: 200px;
  background: #222;
}

.planner-panel {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 16px calc(env(safe-area-inset-bottom, 0px) + 16px);
  background: #0a0a0a;
  border-top: 1px solid #333;
  max-height: 45vh;
  overflow-y: auto;
}

.planner-fields {
  display: flex;
  gap: 14px;
}

.planner-fields label {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
  color: #aaa;
  letter-spacing: 1px;
}

.planner-fields input {
  background: #111;
  color: #fff;
  border: 1px solid #555;
  border-radius: 10px;
  font-size: 22px;
  font-weight: 700;
  text-align: center;
  padding: 12px 10px;
  font-family: "SF Mono", Menlo, Consolas, monospace;
}

.planner-fields input:focus {
  outline: none;
  border-color: #00aa44;
}

.planner-hint {
  font-size: 14px;
  color: #888;
}

.waypoint-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.waypoint-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #141414;
  border: 1px solid #2a2a2a;
  border-radius: 8px;
  padding: 10px 12px;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 14px;
}

.waypoint-list .wp-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #1a3a5a;
  font-weight: 700;
  flex: 0 0 auto;
}

.waypoint-list .wp-coords {
  flex: 1;
  color: #ccc;
}

.waypoint-list .wp-remove {
  background: #3a1414;
  color: #ff6b6b;
  border: 1px solid #5a2a2a;
  border-radius: 6px;
  font-size: 18px;
  line-height: 1;
  padding: 6px 12px;
  cursor: pointer;
}

.planner-panel #btn-plan-send:disabled {
  background: #1f3a2a;
  color: #6a6a6a;
  cursor: default;
}

.planner-panel .ff-url-display {
  margin: 0;
  max-width: 100%;
}

/* Waypoint marker — a CSS dot so we don't depend on Leaflet's image assets */
.wp-marker {
  background: #ff3b30;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.7);
}

/* --- Advisory view --- */

#advisory-view {
  background: #000;
  gap: 20px;
  text-align: center;
  padding: 20px;
}

.alert-header {
  color: #ff0000;
  font-size: 42px;
  font-weight: 900;
  letter-spacing: 2px;
  text-shadow: 0 0 20px rgba(255, 0, 0, 0.5);
}

.traffic-label {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 2px;
  color: #aaa;
}

.traffic-id {
  font-size: 44px;
  font-weight: 900;
  line-height: 1.2;
  color: #fff;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  word-break: break-all;
  max-width: 92%;
}

.advisory-buttons {
  display: flex;
  gap: 20px;
  margin-top: 16px;
  width: 100%;
  max-width: 800px;
}

.btn-advisory {
  flex: 1;
  min-height: 80px;
  border: none;
  border-radius: 12px;
  font-size: 24px;
  font-weight: 800;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.btn-ack {
  background: #cc0000;
  color: #fff;
}

.btn-ack:active {
  background: #990000;
}

.btn-foreflight {
  background: #00aa44;
  color: #fff;
}

.btn-foreflight:active {
  background: #008833;
}

/* --- Settings view --- */

#settings-view {
  gap: 20px;
  text-align: center;
}

#settings-view h2 {
  font-size: 24px;
  font-weight: 600;
}

.settings-field {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 420px;
  text-align: left;
}

.settings-field label {
  font-size: 16px;
  color: #aaa;
  letter-spacing: 1px;
}

#reg-input {
  background: #111;
  color: #fff;
  border: 1px solid #555;
  border-radius: 10px;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  text-align: center;
  padding: 16px 18px;
  font-family: "SF Mono", Menlo, Consolas, monospace;
}

#reg-input:focus {
  outline: none;
  border-color: #00aa44;
}

.settings-msg {
  font-size: 16px;
  color: #aaa;
  min-height: 20px;
}

.settings-buttons {
  display: flex;
  gap: 16px;
  width: 100%;
  max-width: 420px;
}

.btn-settings-save {
  flex: 1;
  background: #00aa44;
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 20px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 18px;
  min-height: 70px;
  cursor: pointer;
}

.btn-settings-save:active {
  background: #008833;
}

#settings-view .btn-debug {
  flex: 1;
  min-height: 70px;
}

/* --- Responsive --- */

@media (max-width: 600px) {
  .traffic-id {
    font-size: 30px;
  }

  .alert-header {
    font-size: 28px;
  }

  .advisory-buttons {
    flex-direction: column;
  }

  .btn-advisory {
    font-size: 20px;
  }
}

@media (min-width: 1024px) {
  .traffic-id {
    font-size: 52px;
  }
}
