/* ===== J.A.R.V.I.S. — HUD ===== */
:root {
  --bg: #04080d;
  --bg-2: #071019;
  --cyan: #4fd8ff;
  --cyan-dim: #1d6d8c;
  --cyan-glow: rgba(79, 216, 255, 0.55);
  --gold: #ffc861;
  --text: #cfeeff;
  --text-dim: #6fa3ba;
  --danger: #ff6b6b;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "SF Mono", "Menlo", "Roboto Mono", "Consolas", monospace;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 30%, rgba(31, 108, 140, 0.14), transparent 60%),
    repeating-linear-gradient(0deg, transparent 0 2px, rgba(79, 216, 255, 0.012) 2px 4px);
  z-index: 0;
}

.hidden { display: none !important; }

/* ===== Arranque ===== */
.boot {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  transition: opacity 0.6s;
}
.boot.fade { opacity: 0; pointer-events: none; }
.boot-inner { text-align: center; padding: 24px; }
.boot-reactor {
  width: 90px; height: 90px;
  margin: 0 auto 28px;
  border-radius: 50%;
  border: 2px solid var(--cyan-dim);
  box-shadow: 0 0 40px var(--cyan-glow), inset 0 0 30px var(--cyan-glow);
  background: radial-gradient(circle, #bdefff 0%, var(--cyan) 25%, transparent 70%);
  animation: bootPulse 1.1s ease-in-out infinite;
}
@keyframes bootPulse {
  0%, 100% { transform: scale(1); opacity: 0.85; }
  50% { transform: scale(1.08); opacity: 1; }
}
.boot-log {
  font-size: 12px;
  color: var(--cyan);
  text-align: left;
  min-height: 130px;
  width: min(320px, 80vw);
  margin: 0 auto;
  white-space: pre-wrap;
  text-shadow: 0 0 8px var(--cyan-glow);
}

/* ===== Layout ===== */
.app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  z-index: 1;
  padding-top: var(--safe-top);
}

.hud-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 14px 18px 8px;
}
.logo {
  font-size: 18px;
  letter-spacing: 4px;
  color: var(--cyan);
  text-shadow: 0 0 12px var(--cyan-glow);
  font-weight: 600;
}
.status {
  margin-top: 4px;
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--text-dim);
}
.status.active { color: var(--gold); text-shadow: 0 0 8px rgba(255, 200, 97, 0.5); }
.hud-right { text-align: right; }
.clock {
  font-size: 20px;
  color: var(--cyan);
  text-shadow: 0 0 10px var(--cyan-glow);
}
.dateline { font-size: 9px; letter-spacing: 1px; color: var(--text-dim); margin-top: 3px; text-transform: uppercase; }

/* ===== Reator ===== */
.reactor-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 0 4px;
  flex-shrink: 0;
}
.reactor {
  position: relative;
  width: 150px;
  height: 150px;
  cursor: pointer;
}
.ring {
  position: absolute;
  border-radius: 50%;
  border: 1.5px solid var(--cyan-dim);
}
.ring-outer {
  inset: 0;
  border-color: rgba(79, 216, 255, 0.35);
  border-top-color: var(--cyan);
  animation: spin 6s linear infinite;
}
.ring-ticks {
  inset: 10px;
  border: none;
  background: repeating-conic-gradient(var(--cyan-dim) 0deg 2deg, transparent 2deg 12deg);
  -webkit-mask: radial-gradient(circle, transparent 62%, #000 63%, #000 100%);
  mask: radial-gradient(circle, transparent 62%, #000 63%, #000 100%);
  animation: spin 14s linear infinite reverse;
  opacity: 0.7;
}
.ring-mid {
  inset: 26px;
  border-color: rgba(79, 216, 255, 0.5);
  border-bottom-color: var(--cyan);
  animation: spin 4s linear infinite reverse;
}
.ring-inner {
  inset: 40px;
  border-color: rgba(79, 216, 255, 0.25);
  box-shadow: inset 0 0 20px rgba(79, 216, 255, 0.25);
}
.core {
  position: absolute;
  inset: 52px;
  border-radius: 50%;
  background: radial-gradient(circle, #eaffff 0%, #9fe8ff 35%, var(--cyan) 65%, rgba(79, 216, 255, 0.1) 100%);
  box-shadow: 0 0 30px var(--cyan-glow), 0 0 70px rgba(79, 216, 255, 0.3);
  transition: transform 0.12s ease-out;
}
.core-glow {
  position: absolute;
  inset: -20px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(79, 216, 255, 0.18) 0%, transparent 65%);
  pointer-events: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

.reactor.idle .core { animation: breathe 3.2s ease-in-out infinite; }
@keyframes breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}
.reactor.listening .core {
  background: radial-gradient(circle, #fff8e8 0%, #ffd98a 35%, var(--gold) 65%, rgba(255, 200, 97, 0.1) 100%);
  box-shadow: 0 0 35px rgba(255, 200, 97, 0.6), 0 0 80px rgba(255, 200, 97, 0.3);
}
.reactor.listening .ring-outer,
.reactor.listening .ring-mid { border-top-color: var(--gold); border-bottom-color: var(--gold); animation-duration: 1.6s; }
.reactor.thinking .ring-outer { animation-duration: 0.9s; }
.reactor.thinking .ring-mid { animation-duration: 0.7s; }
.reactor.speaking .core { animation: talk 0.35s ease-in-out infinite; }
@keyframes talk {
  0%, 100% { transform: scale(0.96); }
  50% { transform: scale(1.09); }
}

.hint {
  margin-top: 10px;
  font-size: 10px;
  letter-spacing: 1.5px;
  color: var(--text-dim);
  text-transform: uppercase;
}

/* ===== Conversa ===== */
.chat {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
  -webkit-user-select: text;
  user-select: text;
}
.msg {
  max-width: 86%;
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.45;
  border-radius: 4px;
  white-space: pre-wrap;
  word-break: break-word;
  animation: msgIn 0.25s ease-out;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
.msg.user {
  align-self: flex-end;
  background: rgba(255, 200, 97, 0.08);
  border: 1px solid rgba(255, 200, 97, 0.35);
  border-right-width: 3px;
  color: #ffe9c4;
}
.msg.jarvis {
  align-self: flex-start;
  background: rgba(79, 216, 255, 0.06);
  border: 1px solid rgba(79, 216, 255, 0.3);
  border-left-width: 3px;
}
.msg.jarvis.streaming::after {
  content: "▊";
  color: var(--cyan);
  animation: blink 0.8s step-start infinite;
}
@keyframes blink { 50% { opacity: 0; } }
.msg .who {
  display: block;
  font-size: 9px;
  letter-spacing: 2px;
  margin-bottom: 5px;
  color: var(--text-dim);
  text-transform: uppercase;
}

/* ===== Barra inferior ===== */
.hud-bottom {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 34px;
  padding: 10px 0 calc(14px + var(--safe-bottom));
}
.round-btn {
  width: 46px; height: 46px;
  border-radius: 50%;
  border: 1px solid var(--cyan-dim);
  background: rgba(79, 216, 255, 0.05);
  color: var(--cyan);
  font-size: 18px;
  cursor: pointer;
  transition: all 0.15s;
}
.round-btn:active { transform: scale(0.92); background: rgba(79, 216, 255, 0.15); }
.round-btn.on {
  border-color: var(--gold);
  color: var(--gold);
  box-shadow: 0 0 15px rgba(255, 200, 97, 0.4);
  background: rgba(255, 200, 97, 0.08);
}
.mic-btn {
  width: 64px; height: 64px;
  border-radius: 50%;
  border: 1.5px solid var(--cyan);
  background: radial-gradient(circle, rgba(79, 216, 255, 0.18), rgba(79, 216, 255, 0.04));
  color: var(--cyan);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 20px rgba(79, 216, 255, 0.25);
  transition: all 0.15s;
}
.mic-btn:active { transform: scale(0.93); }
.mic-btn.on {
  border-color: var(--gold);
  color: var(--gold);
  box-shadow: 0 0 25px rgba(255, 200, 97, 0.5);
  background: radial-gradient(circle, rgba(255, 200, 97, 0.2), rgba(255, 200, 97, 0.04));
}

/* ===== Entrada texto ===== */
.text-bar {
  position: fixed;
  left: 0; right: 0;
  bottom: 0;
  display: flex;
  gap: 8px;
  padding: 10px 12px calc(10px + var(--safe-bottom));
  background: rgba(7, 16, 25, 0.95);
  border-top: 1px solid var(--cyan-dim);
  backdrop-filter: blur(10px);
  z-index: 20;
}
.text-bar input {
  flex: 1;
  background: rgba(79, 216, 255, 0.06);
  border: 1px solid var(--cyan-dim);
  border-radius: 4px;
  color: var(--text);
  font-family: inherit;
  font-size: 16px;
  padding: 11px 13px;
  outline: none;
  -webkit-user-select: text;
  user-select: text;
}
.text-bar input:focus { border-color: var(--cyan); box-shadow: 0 0 12px rgba(79, 216, 255, 0.25); }
.text-bar button {
  width: 48px;
  border: 1px solid var(--cyan);
  border-radius: 4px;
  background: rgba(79, 216, 255, 0.12);
  color: var(--cyan);
  font-size: 17px;
  cursor: pointer;
  flex-shrink: 0;
}
.text-bar #closeText {
  border-color: var(--cyan-dim);
  background: transparent;
  color: var(--text-dim);
}

/* ===== Definições ===== */
.settings {
  position: fixed;
  inset: 0;
  background: rgba(2, 5, 8, 0.75);
  backdrop-filter: blur(6px);
  z-index: 50;
  display: flex;
  justify-content: flex-end;
}
.settings-sheet {
  width: min(420px, 100%);
  height: 100%;
  background: var(--bg-2);
  border-left: 1px solid var(--cyan-dim);
  overflow-y: auto;
  padding: calc(16px + var(--safe-top)) 20px calc(30px + var(--safe-bottom));
  animation: slideIn 0.25s ease-out;
}
@keyframes slideIn {
  from { transform: translateX(40px); opacity: 0; }
  to { transform: none; opacity: 1; }
}
.settings-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}
.settings h2 { font-size: 16px; letter-spacing: 3px; color: var(--cyan); }
.settings h3 {
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--gold);
  text-transform: uppercase;
  margin-bottom: 12px;
  border-bottom: 1px solid rgba(255, 200, 97, 0.2);
  padding-bottom: 6px;
}
.settings section { margin-bottom: 26px; }
.settings label {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 14px;
}
.settings input[type="text"],
.settings input[type="password"],
.settings select {
  display: block;
  width: 100%;
  margin-top: 6px;
  background: rgba(79, 216, 255, 0.05);
  border: 1px solid var(--cyan-dim);
  border-radius: 4px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  padding: 10px 12px;
  outline: none;
  -webkit-user-select: text;
  user-select: text;
}
.settings input[type="range"] { width: 100%; margin-top: 8px; accent-color: var(--cyan); }
.toggle-row {
  display: flex !important;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.toggle-row input { width: 22px; height: 22px; accent-color: var(--cyan); }
.ghost-btn {
  width: 100%;
  padding: 12px;
  background: transparent;
  border: 1px solid var(--cyan-dim);
  border-radius: 4px;
  color: var(--cyan);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  margin-top: 4px;
}
.ghost-btn.danger { border-color: rgba(255, 107, 107, 0.5); color: var(--danger); }
.note { font-size: 11px; color: var(--text-dim); line-height: 1.5; margin-top: 10px; }
.note a { color: var(--cyan); }

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: calc(110px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  max-width: 88vw;
  background: rgba(7, 16, 25, 0.95);
  border: 1px solid var(--gold);
  color: var(--gold);
  font-size: 12px;
  padding: 10px 16px;
  border-radius: 4px;
  z-index: 60;
  animation: msgIn 0.2s ease-out;
  text-align: center;
}

@media (max-height: 640px) {
  .reactor { width: 110px; height: 110px; }
  .ring-mid { inset: 19px; }
  .ring-inner { inset: 30px; }
  .core { inset: 38px; }
}
