/* FRED Web v5.1.0 — Interface Futurista Robótica
   Autor: Marlon Rodrigues — FLASH DEV (https://flashdev.com.br)
   Data: 22/04/2026 14:22 */

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

:root {
  --bg-deep: #05060e;
  --bg-panel: #0a0c18;
  --bg-card: rgba(12, 16, 32, 0.85);
  --accent: #00ffc8;
  --accent-dim: #00b890;
  --accent-glow: rgba(0, 255, 200, 0.25);
  --danger: #ff2255;
  --danger-glow: rgba(255, 34, 85, 0.3);
  --warn: #ffaa00;
  --text: #e0e6f0;
  --text-dim: #6a7490;
  --border: rgba(0, 255, 200, 0.12);
  --border-bright: rgba(0, 255, 200, 0.35);
  --radius: 12px;
  --radius-sm: 8px;
  --font-display: 'Orbitron', monospace;
  --font-body: 'Inter', -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--bg-deep);
  color: var(--text);
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ─── BG ─── */
.grid-bg {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    linear-gradient(rgba(0,255,200,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,255,200,0.03) 1px, transparent 1px);
  background-size: 40px 40px;
}
.scanline {
  position: fixed; inset: 0; z-index: 9999; pointer-events: none;
  background: repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0,0,0,0.03) 2px, rgba(0,0,0,0.03) 4px);
}

/* ─── APP ─── */
#app {
  position: relative; z-index: 1;
  max-width: 480px; margin: 0 auto;
  padding: 0 12px;
  display: flex; flex-direction: column;
  min-height: 100dvh;
}

/* ─── HEADER ─── */
#header { padding: 16px 0 8px; }

.hud-frame {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  backdrop-filter: blur(12px);
  overflow: hidden;
}
.hud-frame::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  animation: scanBar 3s ease-in-out infinite;
}
@keyframes scanBar {
  0%, 100% { opacity: 0.3; transform: scaleX(0.3); }
  50% { opacity: 1; transform: scaleX(1); }
}
.hud-corner { position: absolute; width: 12px; height: 12px; border-color: var(--accent); border-style: solid; }
.hud-corner.tl { top: -1px; left: -1px; border-width: 2px 0 0 2px; border-radius: 4px 0 0 0; }
.hud-corner.tr { top: -1px; right: -1px; border-width: 2px 2px 0 0; border-radius: 0 4px 0 0; }

.header-content { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.fred-identity { display: flex; align-items: center; gap: 14px; }

/* ─── ROBOT AVATAR ─── */
.robot-avatar {
  position: relative; width: 48px; height: 48px;
  display: flex; align-items: center; justify-content: center;
}
.robot-img {
  width: 44px; height: 44px; border-radius: 50%; object-fit: cover;
  position: relative; z-index: 2;
  filter: drop-shadow(0 0 8px var(--accent-glow));
  animation: avatarFloat 3s ease-in-out infinite;
}
@keyframes avatarFloat { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
.avatar-glow {
  position: absolute; inset: -5px;
  border: 2px solid var(--accent); border-radius: 50%; opacity: 0.5;
  animation: glowPulse 2s ease-in-out infinite;
  border-top-color: transparent; border-left-color: transparent;
}
@keyframes glowPulse {
  0%, 100% { transform: rotate(0deg) scale(1); opacity: 0.3; }
  50% { transform: rotate(180deg) scale(1.1); opacity: 0.7; }
}

.fred-info h1 {
  font-family: var(--font-display); font-weight: 900; font-size: 28px;
  letter-spacing: 6px;
  background: linear-gradient(135deg, var(--accent), #00ddff);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  line-height: 1;
}
.subtitle {
  display: block; font-family: var(--font-mono);
  font-size: 9px; letter-spacing: 2px; color: var(--text-dim); margin-top: 4px;
}
.system-status {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  background: rgba(0,255,200,0.06); border: 1px solid var(--border); border-radius: 20px;
}
.status-dot {
  width: 8px; height: 8px; background: var(--accent); border-radius: 50%;
  box-shadow: 0 0 8px var(--accent-glow); animation: blink 2s ease-in-out infinite;
}
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }
.status-text { font-family: var(--font-mono); font-size: 10px; letter-spacing: 1px; color: var(--accent-dim); }

.status-listening .status-dot { background: var(--warn); box-shadow: 0 0 8px rgba(255,170,0,0.4); }
.status-listening .status-text { color: var(--warn); }
.status-processing .status-dot { background: #00aaff; box-shadow: 0 0 8px rgba(0,170,255,0.4); animation: blink 0.5s ease-in-out infinite; }
.status-processing .status-text { color: #00aaff; }
.status-speaking .status-dot { background: #aa44ff; box-shadow: 0 0 8px rgba(170,68,255,0.4); }
.status-speaking .status-text { color: #aa44ff; }
.status-error .status-dot { background: var(--danger); }
.status-error .status-text { color: var(--danger); }

/* ─── VOICE ─── */
#voiceSection { padding: 20px 0 10px; }
.voice-container { text-align: center; }

.waveform {
  display: flex; align-items: center; justify-content: center;
  gap: 3px; height: 50px; margin-bottom: 16px;
  opacity: 0; transition: opacity 0.4s;
}
.waveform.active { opacity: 1; }
.wave-bar {
  width: 4px; border-radius: 4px;
  background: linear-gradient(180deg, var(--accent), var(--accent-dim));
  height: 8px; transition: height 0.1s;
}
.waveform.active .wave-bar { animation: waveAnim 0.6s ease-in-out infinite alternate; }
@keyframes waveAnim { 0% { height: 6px; opacity: 0.4; } 100% { height: 40px; opacity: 1; } }
.wave-bar:nth-child(1) { animation-delay: 0.00s; } .wave-bar:nth-child(2) { animation-delay: 0.05s; }
.wave-bar:nth-child(3) { animation-delay: 0.10s; } .wave-bar:nth-child(4) { animation-delay: 0.15s; }
.wave-bar:nth-child(5) { animation-delay: 0.20s; } .wave-bar:nth-child(6) { animation-delay: 0.25s; }
.wave-bar:nth-child(7) { animation-delay: 0.30s; } .wave-bar:nth-child(8) { animation-delay: 0.35s; }
.wave-bar:nth-child(9) { animation-delay: 0.40s; } .wave-bar:nth-child(10) { animation-delay: 0.45s; }
.wave-bar:nth-child(11) { animation-delay: 0.40s; } .wave-bar:nth-child(12) { animation-delay: 0.35s; }
.wave-bar:nth-child(13) { animation-delay: 0.30s; } .wave-bar:nth-child(14) { animation-delay: 0.25s; }
.wave-bar:nth-child(15) { animation-delay: 0.20s; } .wave-bar:nth-child(16) { animation-delay: 0.15s; }
.wave-bar:nth-child(17) { animation-delay: 0.10s; } .wave-bar:nth-child(18) { animation-delay: 0.05s; }
.wave-bar:nth-child(19) { animation-delay: 0.00s; } .wave-bar:nth-child(20) { animation-delay: 0.05s; }

.voice-btn {
  position: relative; width: 80px; height: 80px; border-radius: 50%;
  background: linear-gradient(145deg, var(--bg-panel), #0e1028);
  border: 2px solid var(--border-bright); color: var(--accent); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto; transition: all 0.3s;
  box-shadow: 0 0 30px var(--accent-glow), inset 0 0 20px rgba(0,255,200,0.05);
}
.voice-btn:hover { transform: scale(1.08); box-shadow: 0 0 50px var(--accent-glow); border-color: var(--accent); }
.voice-btn:active { transform: scale(0.95); }
.voice-btn.listening {
  border-color: var(--danger); color: var(--danger);
  box-shadow: 0 0 40px var(--danger-glow);
  animation: pulseRed 1.5s ease-in-out infinite;
}
@keyframes pulseRed {
  0%, 100% { box-shadow: 0 0 30px var(--danger-glow); }
  50% { box-shadow: 0 0 60px var(--danger-glow); }
}
.mic-icon, .stop-icon { width: 32px; height: 32px; }
.hidden { display: none; }

.voice-label {
  margin-top: 12px; font-family: var(--font-mono);
  font-size: 11px; letter-spacing: 2px; color: var(--text-dim); transition: color 0.3s;
}
.voice-label.active { color: var(--warn); }
.voice-transcript {
  margin-top: 8px; font-family: var(--font-mono);
  font-size: 12px; color: var(--accent-dim);
  min-height: 18px; max-width: 90%; margin-left: auto; margin-right: auto;
  word-break: break-word;
}

/* ─── CHAT (max-height fixo, scrolla internamente) ─── */
#chatSection { padding: 8px 0; }

.chat-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  min-height: 100px;
  max-height: 160px;
  overflow-y: auto;
  backdrop-filter: blur(8px);
  scroll-behavior: smooth;
}
.chat-container::-webkit-scrollbar { width: 4px; }
.chat-container::-webkit-scrollbar-track { background: transparent; }
.chat-container::-webkit-scrollbar-thumb { background: var(--border-bright); border-radius: 4px; }

.chat-welcome { text-align: center; padding: 30px 10px; color: var(--text-dim); }
.welcome-icon { font-size: 40px; margin-bottom: 12px; }
.chat-welcome p { font-size: 14px; margin-bottom: 4px; }
.chat-welcome strong { color: var(--accent); font-weight: 700; }
.welcome-sub { font-size: 12px; opacity: 0.6; }

.chat-msg { margin-bottom: 12px; animation: fadeIn 0.3s ease-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.chat-msg.user { text-align: right; }
.chat-msg.user .chat-bubble {
  background: linear-gradient(135deg, rgba(0,255,200,0.12), rgba(0,180,255,0.08));
  border: 1px solid rgba(0,255,200,0.2);
  border-radius: var(--radius-sm) var(--radius-sm) 4px var(--radius-sm);
  margin-left: 40px;
}
.chat-msg.fred .chat-bubble {
  background: linear-gradient(135deg, rgba(60,40,120,0.2), rgba(30,30,60,0.3));
  border: 1px solid rgba(120,80,220,0.2);
  border-radius: var(--radius-sm) var(--radius-sm) var(--radius-sm) 4px;
  margin-right: 40px;
}
.chat-bubble {
  display: inline-block; padding: 10px 14px;
  font-size: 14px; line-height: 1.5; max-width: 100%; word-break: break-word;
}
.chat-sender {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 1px;
  margin-bottom: 4px; opacity: 0.5;
}
.chat-msg.user .chat-sender { color: var(--accent); }
.chat-msg.fred .chat-sender { color: #aa66ff; }

/* ─── INPUT ─── */
#inputSection { padding: 8px 0; }
.input-frame {
  display: flex; gap: 8px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 6px;
  backdrop-filter: blur(8px); transition: border-color 0.3s;
}
.input-frame:focus-within { border-color: var(--accent-dim); }
#chatInput {
  flex: 1; background: transparent; border: none; outline: none;
  color: var(--text); font-family: var(--font-body); font-size: 14px;
  padding: 10px 12px;
}
#chatInput::placeholder { color: var(--text-dim); }
#sendBtn {
  width: 44px; height: 44px; border: none; border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent-dim), var(--accent));
  color: var(--bg-deep); cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: all 0.2s;
}
#sendBtn:hover { transform: scale(1.05); }
#sendBtn:active { transform: scale(0.95); }
#sendBtn svg { width: 18px; height: 18px; }

/* ─── SECTIONS ─── */
.section-title {
  display: flex; align-items: center; gap: 6px;
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 2px;
  color: var(--text-dim); margin-bottom: 10px; padding: 0 4px;
}
.section-title svg { color: var(--accent-dim); }

#presetsSection { padding: 8px 0; }
.presets-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.preset-btn {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 8px;
  color: var(--text); cursor: pointer; text-align: center;
  font-family: var(--font-body); font-size: 12px;
  transition: all 0.2s; line-height: 1.3;
}
.preset-btn:hover { border-color: var(--accent-dim); background: rgba(0,255,200,0.06); transform: translateY(-2px); }
.preset-btn:active { transform: scale(0.96); }
.preset-icon { display: block; font-size: 22px; margin-bottom: 4px; }
.preset-label { font-family: var(--font-mono); font-size: 9px; letter-spacing: 1px; color: var(--text-dim); }

#sfxSection { padding: 8px 0 20px; }
.sfx-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.sfx-btn {
  aspect-ratio: 1;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 11px; transition: all 0.2s; gap: 2px;
}
.sfx-btn:hover { border-color: var(--accent-dim); transform: scale(1.08); box-shadow: 0 0 15px var(--accent-glow); }
.sfx-btn:active { transform: scale(0.92); background: rgba(0,255,200,0.1); }
.sfx-emoji { font-size: 20px; }
.sfx-name { font-family: var(--font-mono); font-size: 7px; letter-spacing: 1px; color: var(--text-dim); }

/* ─── FOOTER ─── */
#footer {
  padding: 12px 0; padding-bottom: calc(12px + var(--safe-bottom));
  border-top: 1px solid var(--border);
}
.footer-content {
  display: flex; justify-content: space-between; align-items: center;
  font-family: var(--font-mono); font-size: 9px; letter-spacing: 1px; color: var(--text-dim);
}
.footer-brand { opacity: 0.4; }
.footer-dev a { color: var(--accent-dim); text-decoration: none; }
.footer-dev a:hover { color: var(--accent); }

/* ─── TYPING ─── */
.typing-indicator { display: inline-flex; gap: 4px; padding: 6px 0; }
.typing-dot {
  width: 6px; height: 6px; background: var(--accent-dim); border-radius: 50%;
  animation: typingBounce 1s ease-in-out infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.15s; }
.typing-dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-8px); opacity: 1; }
}

/* ─── RESPONSIVE ─── */
@media (min-width: 768px) {
  #app { max-width: 520px; }
  .chat-container { max-height: 350px; }
}
@media (max-width: 380px) {
  .presets-grid { grid-template-columns: repeat(3, 1fr); }
  .sfx-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
