/* PWA shell on top of the editor's style.css. */

/* Make room for the control bar. */
body.pwa-mode #workspace { bottom: 56px; }
body.pwa-mode #workspace.with-output { bottom: calc(30vh + 56px); }
body.pwa-mode #output { bottom: 56px; }

#pwa-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 56px;
  background: #ffffff;
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.12);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  z-index: 60;
}

#pwa-status {
  flex: 1;
  font-weight: 600;
  color: #6b7280;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#pwa-status.ok { color: #2563eb; }
#pwa-status.running { color: #16a34a; }

#pwa-bar button {
  border: 0;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  background: #e5e7eb;
  color: #111827;
}
#pwa-bar #pwa-connect { background: #3478f6; color: white; }
#pwa-bar #pwa-run { background: #16a34a; color: white; }
#pwa-bar #pwa-run:disabled { opacity: 0.5; }
#pwa-bar #pwa-stop { background: #dc2626; color: white; }

#pwa-toast {
  position: fixed;
  left: 50%;
  bottom: 72px;
  transform: translateX(-50%) translateY(20px);
  background: #111827;
  color: white;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 14px;
  max-width: 85vw;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 200;
}
#pwa-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* RC overlay */
#pwa-rc-overlay {
  position: fixed;
  inset: 0;
  background: #032b30;
  z-index: 150;
  display: flex;
  flex-direction: column;
  align-items: center;
  color: white;
  touch-action: none;
}
#pwa-rc-overlay[hidden] { display: none; }

#pwa-rc-top {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
  box-sizing: border-box;
  font-weight: 600;
}
#pwa-rc-top button {
  background: rgba(255, 255, 255, 0.15);
  border: 0;
  color: white;
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
}

#pwa-rc-buttons {
  display: flex;
  gap: 24px;
  margin: 6vh 0;
}
#pwa-rc-buttons button {
  background: rgba(255, 255, 255, 0.15);
  border: 0;
  color: white;
  font-size: 18px;
  border-radius: 14px;
  padding: 18px 22px;
  cursor: pointer;
}
#pwa-rc-buttons button.active { background: #f59e0b; color: #111827; }

#pwa-joystick {
  width: min(64vw, 300px);
  height: min(64vw, 300px);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 3px solid rgba(255, 255, 255, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
  margin-top: auto;
  margin-bottom: 8vh;
}
#pwa-thumb {
  width: 34%;
  height: 34%;
  border-radius: 50%;
  background: #2dd4bf;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.4);
  pointer-events: none;
}

/* Config modal */
#pwa-cfg-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 180;
  display: flex;
  align-items: center;
  justify-content: center;
}
#pwa-cfg-overlay[hidden] { display: none; }

#pwa-cfg {
  background: white;
  border-radius: 14px;
  width: min(92vw, 460px);
  max-height: 84vh;
  display: flex;
  flex-direction: column;
  padding: 18px;
  box-sizing: border-box;
}
#pwa-cfg-title { font-weight: 700; font-size: 17px; margin-bottom: 12px; }
#pwa-cfg-fields { overflow-y: auto; flex: 1; }

.pwa-cfg-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px solid #f3f4f6;
  font-size: 14px;
}
.pwa-cfg-row input[type="number"],
.pwa-cfg-row input[type="text"] {
  width: 130px;
  padding: 6px 8px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
}

#pwa-cfg-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}
#pwa-cfg-actions button {
  border: 0;
  border-radius: 8px;
  padding: 9px 18px;
  font-size: 14px;
  cursor: pointer;
}
#pwa-cfg-cancel { background: #e5e7eb; }
#pwa-cfg-save { background: #3478f6; color: white; }
