/* ==========================================================================
   FALA TALK - Professional Walkie-Talkie & AI Speech Translator
   ========================================================================== */

:root {
  --bg-dark: #070a12;
  --bg-card: rgba(15, 23, 42, 0.75);
  --bg-card-border: rgba(255, 255, 255, 0.08);
  --bg-card-hover: rgba(30, 41, 59, 0.85);

  --pt-color: #10b981;
  --pt-glow: rgba(16, 185, 129, 0.35);
  --pt-bg-active: linear-gradient(135deg, #059669 0%, #047857 100%);
  --pt-border: #34d399;

  --ja-color: #f43f5e;
  --ja-glow: rgba(244, 63, 94, 0.35);
  --ja-bg-active: linear-gradient(135deg, #e11d48 0%, #be123c 100%);
  --ja-border: #fb7185;

  --primary-accent: #38bdf8;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --font-main: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-jp: 'Noto Sans JP', 'Hiragino Sans', sans-serif;
  --radius-xl: 20px;
  --radius-lg: 14px;
  --radius-md: 10px;
  --radius-full: 9999px;
}

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

body {
  font-family: var(--font-main);
  background-color: var(--bg-dark);
  background-image: 
    radial-gradient(at 0% 0%, rgba(16, 185, 129, 0.08) 0px, transparent 50%),
    radial-gradient(at 100% 0%, rgba(244, 63, 94, 0.08) 0px, transparent 50%),
    radial-gradient(at 50% 50%, rgba(56, 189, 248, 0.04) 0px, transparent 60%);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
}

.talk-wrapper {
  width: 100%;
  max-width: 720px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 1rem 1rem 2rem;
  margin: 0 auto;
}

/* ==========================================================================
   Header
   ========================================================================== */
.talk-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-xl);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
  margin-bottom: 1.25rem;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.brand-badge {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  border: 1px solid rgba(56, 189, 248, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary-accent);
  font-size: 1.25rem;
  box-shadow: 0 0 15px rgba(56, 189, 248, 0.2);
}

.brand-info h1 {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
  color: #ffffff;
}

.brand-info h1 span {
  color: var(--primary-accent);
}

.brand-sub {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.ctrl-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
  border-radius: var(--radius-full);
  padding: 0.5rem 0.85rem;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.2s ease;
}

.ctrl-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

.ctrl-btn.active {
  background: rgba(56, 189, 248, 0.15);
  border-color: rgba(56, 189, 248, 0.4);
  color: var(--primary-accent);
}

/* ==========================================================================
   Communicator Panel
   ========================================================================== */
.communicator-panel {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  flex: 1;
}

/* Status & Live Preview */
.status-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.85rem 1rem;
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-lg);
  gap: 0.5rem;
  min-height: 70px;
  text-align: center;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.9rem;
  background: rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-full);
  border: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  transition: all 0.2s ease;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #64748b;
  transition: all 0.2s ease;
}

.status-container.listening-pt .status-dot {
  background: var(--pt-color);
  box-shadow: 0 0 10px var(--pt-color);
  animation: pulseDot 1.2s infinite;
}

.status-container.listening-ja .status-dot {
  background: var(--ja-color);
  box-shadow: 0 0 10px var(--ja-color);
  animation: pulseDot 1.2s infinite;
}

.status-container.translating .status-dot {
  background: #fbbf24;
  box-shadow: 0 0 10px #fbbf24;
  animation: pulseDot 0.6s infinite;
}

.status-container.speaking .status-dot {
  background: var(--primary-accent);
  box-shadow: 0 0 10px var(--primary-accent);
  animation: pulseDot 0.8s infinite;
}

@keyframes pulseDot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.4); opacity: 0.6; }
}

/* Soundwave animation */
.voice-wave {
  display: none;
  align-items: center;
  gap: 4px;
  height: 22px;
}

.status-container.active-wave .voice-wave {
  display: flex;
}

.wave-bar {
  width: 4px;
  height: 6px;
  border-radius: 4px;
  background: var(--primary-accent);
  animation: waveMotion 0.8s ease-in-out infinite;
}

.status-container.listening-pt .wave-bar { background: var(--pt-color); }
.status-container.listening-ja .wave-bar { background: var(--ja-color); }

.wave-bar:nth-child(1) { animation-delay: 0.0s; }
.wave-bar:nth-child(2) { animation-delay: 0.1s; }
.wave-bar:nth-child(3) { animation-delay: 0.2s; }
.wave-bar:nth-child(4) { animation-delay: 0.3s; }
.wave-bar:nth-child(5) { animation-delay: 0.4s; }
.wave-bar:nth-child(6) { animation-delay: 0.3s; }
.wave-bar:nth-child(7) { animation-delay: 0.2s; }
.wave-bar:nth-child(8) { animation-delay: 0.1s; }

@keyframes waveMotion {
  0%, 100% { height: 6px; }
  50% { height: 22px; }
}

.live-preview {
  font-size: 0.95rem;
  color: #ffffff;
  font-weight: 500;
  max-width: 90%;
  word-break: break-word;
  display: none;
}

.live-preview.visible {
  display: block;
}

/* ==========================================================================
   Two PTT Buttons (The Core Hero Section)
   ========================================================================== */
.ptt-action-zone {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.ptt-button {
  position: relative;
  background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
  border: 2px solid var(--bg-card-border);
  border-radius: var(--radius-xl);
  padding: 1.5rem 1rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

.ptt-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 28px -4px rgba(0, 0, 0, 0.6);
}

.ptt-button:active,
.ptt-button.recording {
  transform: translateY(2px) scale(0.98);
}

/* Português Button */
.ptt-button.btn-portugues {
  border-color: rgba(16, 185, 129, 0.3);
}

.ptt-button.btn-portugues:hover {
  border-color: var(--pt-border);
  box-shadow: 0 0 25px var(--pt-glow);
}

.ptt-button.btn-portugues.recording {
  background: var(--pt-bg-active);
  border-color: #6ee7b7;
  box-shadow: 0 0 35px var(--pt-glow), inset 0 2px 5px rgba(0,0,0,0.3);
}

/* Japonês Button */
.ptt-button.btn-japones {
  border-color: rgba(244, 63, 94, 0.3);
}

.ptt-button.btn-japones:hover {
  border-color: var(--ja-border);
  box-shadow: 0 0 25px var(--ja-glow);
}

.ptt-button.btn-japones.recording {
  background: var(--ja-bg-active);
  border-color: #fda4af;
  box-shadow: 0 0 35px var(--ja-glow), inset 0 2px 5px rgba(0,0,0,0.3);
}

.ptt-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
}

.ptt-flag-ring {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.btn-portugues .ptt-flag-ring {
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.3);
}

.btn-japones .ptt-flag-ring {
  background: rgba(244, 63, 94, 0.1);
  border-color: rgba(244, 63, 94, 0.3);
}

.flag-icon {
  font-size: 2.2rem;
  line-height: 1;
}

.mic-icon-bubble {
  position: absolute;
  bottom: -4px;
  right: -4px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #0f172a;
  border: 2px solid #334155;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  color: #94a3b8;
  transition: all 0.2s ease;
}

.btn-portugues .mic-icon-bubble { color: var(--pt-color); border-color: var(--pt-color); }
.btn-japones .mic-icon-bubble { color: var(--ja-color); border-color: var(--ja-color); }

.ptt-button.recording .mic-icon-bubble {
  background: #ffffff;
  color: #0f172a;
  transform: scale(1.15);
}

.ptt-labels {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.ptt-title {
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: #ffffff;
}

.btn-japones .ptt-title {
  font-family: var(--font-jp);
  font-size: 1.05rem;
}

.ptt-subtitle {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
}

.ptt-button.recording .ptt-subtitle {
  color: #f1f5f9;
}

.ptt-touch-hint {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.2rem 0.6rem;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-full);
  color: var(--text-dim);
}

.ptt-button.recording .ptt-touch-hint {
  background: rgba(0, 0, 0, 0.25);
  color: #ffffff;
}

/* ==========================================================================
   Text Input Fallback Accordion
   ========================================================================== */
.text-fallback-wrapper {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.text-fallback-header {
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s ease;
}

.text-fallback-header:hover {
  background: rgba(255, 255, 255, 0.04);
  color: #ffffff;
}

.text-fallback-body {
  padding: 0.75rem 1rem 1rem;
  border-top: 1px solid var(--bg-card-border);
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

#txt-manual-input {
  width: 100%;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  padding: 0.65rem 0.85rem;
  color: #ffffff;
  font-family: var(--font-main);
  font-size: 0.88rem;
  resize: vertical;
}

#txt-manual-input:focus {
  outline: none;
  border-color: var(--primary-accent);
}

.fallback-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.manual-send-btn {
  padding: 0.55rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}

.manual-send-btn.send-pt {
  background: rgba(16, 185, 129, 0.15);
  border-color: rgba(16, 185, 129, 0.4);
  color: #34d399;
}

.manual-send-btn.send-pt:hover {
  background: var(--pt-color);
  color: #ffffff;
}

.manual-send-btn.send-ja {
  background: rgba(244, 63, 94, 0.15);
  border-color: rgba(244, 63, 94, 0.4);
  color: #fb7185;
}

.manual-send-btn.send-ja:hover {
  background: var(--ja-color);
  color: #ffffff;
}

/* ==========================================================================
   Conversation Feed
   ========================================================================== */
.conversation-feed-card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-xl);
  padding: 1.1rem;
  box-shadow: 0 4px 25px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  min-height: 250px;
}

.feed-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.feed-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-main);
}

.feed-title i {
  color: var(--primary-accent);
}

.feed-count {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-dim);
}

.messages-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  max-height: 480px;
  overflow-y: auto;
  padding-right: 4px;
}

.messages-list::-webkit-scrollbar {
  width: 5px;
}
.messages-list::-webkit-scrollbar-track {
  background: transparent;
}
.messages-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2.5rem 1rem;
  text-align: center;
  gap: 0.5rem;
}

.empty-icon {
  font-size: 2.5rem;
  color: var(--text-dim);
  opacity: 0.4;
  margin-bottom: 0.25rem;
}

.empty-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-muted);
}

.empty-sub {
  font-size: 0.8rem;
  color: var(--text-dim);
  max-width: 320px;
}

/* Message Card */
.message-card {
  border-radius: var(--radius-lg);
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  animation: fadeIn 0.25s ease-out forwards;
  position: relative;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.message-card.from-pt {
  background: rgba(16, 185, 129, 0.05);
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-left: 4px solid var(--pt-color);
}

.message-card.from-ja {
  background: rgba(244, 63, 94, 0.05);
  border: 1px solid rgba(244, 63, 94, 0.2);
  border-left: 4px solid var(--ja-color);
}

.msg-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.msg-speaker {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  font-weight: 700;
}

.from-pt .msg-speaker { color: #34d399; }
.from-ja .msg-speaker { color: #fb7185; }

.msg-time {
  font-size: 0.68rem;
  color: var(--text-dim);
}

.msg-original {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.msg-translation-box {
  background: rgba(0, 0, 0, 0.35);
  border-radius: var(--radius-md);
  padding: 0.65rem 0.85rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.msg-translation-text {
  font-size: 1.05rem;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.45;
  flex: 1;
}

.from-pt .msg-translation-text {
  font-family: var(--font-jp);
}

.msg-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.msg-action-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  transition: all 0.15s ease;
}

.msg-action-btn:hover {
  background: rgba(255, 255, 255, 0.18);
  color: #ffffff;
  transform: scale(1.05);
}

.msg-action-btn.btn-play-audio {
  color: var(--primary-accent);
}

/* ==========================================================================
   Footer
   ========================================================================== */
.talk-footer {
  margin-top: auto;
  padding-top: 1.5rem;
  text-align: center;
  font-size: 0.7rem;
  color: var(--text-dim);
}

/* ==========================================================================
   Mobile Optimization
   ========================================================================== */
@media (max-width: 600px) {
  .talk-wrapper {
    padding: 0.75rem 0.65rem 1.5rem;
  }

  .ptt-action-zone {
    gap: 0.65rem;
  }

  .ptt-button {
    padding: 1.25rem 0.6rem;
  }

  .ptt-flag-ring {
    width: 60px;
    height: 60px;
  }

  .flag-icon {
    font-size: 1.8rem;
  }

  .ptt-title {
    font-size: 0.85rem;
  }

  .ptt-subtitle {
    font-size: 0.68rem;
  }

  .ptt-touch-hint {
    font-size: 0.6rem;
  }
}
