/* ========================================
   Dieguito — Dark Suave
   ======================================== */

:root {
  --bg: #16171A;
  --bg-card: #1F2126;
  --bg-card-2: #262932;
  --texto: #D4D4D0;
  --texto-dim: #8C8C88;
  --texto-faint: #5A5A57;
  --acao: #C97B5C;
  --acao-hover: #B86A4D;
  --acento: #B8956A;
  --linha: #2A2D33;
  --erro: #B85C5C;
  --sucesso: #6B8C5C;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}

body {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--texto);
  user-select: none;
  -webkit-user-select: none;
  overscroll-behavior: none;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}

/* ---------- HEADER ---------- */
.header {
  padding: 24px 24px 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.logo {
  font-family: 'Bungee', sans-serif;
  font-size: 26px;
  color: var(--texto);
  line-height: 1;
  letter-spacing: -0.5px;
  font-weight: 400;
}

.logo-sub {
  font-size: 12px;
  color: var(--texto-dim);
  margin-top: 6px;
  font-weight: 500;
  transition: color 0.2s ease;
}

.menu {
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
}

.menu-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--texto-dim);
}

/* ---------- CONTENT ---------- */
.content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 24px;
  position: relative;
}

.state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  text-align: center;
  animation: fadeIn 0.3s ease;
}

.state[hidden] { display: none !important; }

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

.prompt {
  font-size: 14px;
  color: var(--texto-dim);
  margin-bottom: 36px;
  font-weight: 400;
}

/* ---------- MIC BUTTON ---------- */
.mic-button {
  width: 132px;
  height: 132px;
  border-radius: 50%;
  background: var(--acao);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: all 0.2s ease;
  box-shadow:
    0 8px 24px rgba(201, 123, 92, 0.2),
    0 2px 6px rgba(0, 0, 0, 0.3);
  -webkit-tap-highlight-color: transparent;
}

.mic-button:active {
  transform: translateY(1px);
  box-shadow:
    0 4px 12px rgba(201, 123, 92, 0.2),
    0 1px 3px rgba(0, 0, 0, 0.3);
}

.mic-icon {
  width: 52px;
  height: 52px;
  fill: none;
  stroke: var(--bg);
  stroke-width: 3.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.92;
}

/* ---------- TEXT TOGGLE (idle) ---------- */
.text-toggle {
  margin-top: 28px;
  background: transparent;
  border: 1px solid var(--linha);
  color: var(--texto-dim);
  padding: 8px 16px;
  border-radius: 999px;
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.text-toggle:hover,
.text-toggle:focus-visible {
  color: var(--texto);
  border-color: var(--texto-dim);
  outline: none;
}

.text-toggle:active {
  background: var(--bg-card);
  transform: translateY(1px);
}

/* ---------- LISTENING STATE ---------- */
.pulse {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--acao);
  opacity: 0;
  animation: pulse 2.2s ease-out infinite;
  pointer-events: none;
}
.pulse:nth-child(2) { animation-delay: 0.7s; }
.pulse:nth-child(3) { animation-delay: 1.4s; }

@keyframes pulse {
  0%   { transform: scale(1);   opacity: 0.4; }
  100% { transform: scale(1.5); opacity: 0; }
}

.waveform {
  display: flex;
  gap: 4px;
  align-items: center;
  height: 24px;
  margin-top: 32px;
}

.bar {
  width: 3px;
  background: var(--texto-dim);
  border-radius: 2px;
  animation: wave 1s ease-in-out infinite;
}
.bar:nth-child(1) { height: 8px;  animation-delay: 0.0s; }
.bar:nth-child(2) { height: 16px; animation-delay: 0.1s; }
.bar:nth-child(3) { height: 12px; animation-delay: 0.2s; }
.bar:nth-child(4) { height: 20px; animation-delay: 0.3s; }
.bar:nth-child(5) { height: 10px; animation-delay: 0.4s; }
.bar:nth-child(6) { height: 14px; animation-delay: 0.5s; }
.bar:nth-child(7) { height: 9px;  animation-delay: 0.6s; }

@keyframes wave {
  0%, 100% { transform: scaleY(0.6); opacity: 0.5; }
  50%      { transform: scaleY(1.2); opacity: 1; }
}

/* ---------- CONFIRM STATE ---------- */
.state-confirm {
  justify-content: flex-start;
  padding-top: 40px;
}

.transcription-card {
  background: var(--bg-card);
  border: 1px solid var(--linha);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
  text-align: left;
  width: 100%;
}

.transcription-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--acao);
  margin-bottom: 10px;
  font-weight: 600;
  opacity: 0.85;
}

.transcription-text {
  font-size: 16px;
  color: var(--texto);
  line-height: 1.45;
  font-weight: 400;
}

/* Auto-send progress bar */
.autosend-bar {
  width: 100%;
  margin-bottom: 16px;
  position: relative;
}

.autosend-progress {
  height: 3px;
  background: var(--acao);
  border-radius: 2px;
  width: 100%;
  transform-origin: left;
  animation: countdown 5s linear forwards;
  opacity: 0.6;
}

@keyframes countdown {
  from { transform: scaleX(1); }
  to   { transform: scaleX(0); }
}

.autosend-label {
  font-size: 11px;
  color: var(--texto-faint);
  margin-top: 6px;
  text-align: center;
  letter-spacing: 0.3px;
}

.confirm-buttons {
  display: flex;
  gap: 10px;
  width: 100%;
}

.btn {
  flex: 1;
  padding: 13px;
  border-radius: 10px;
  border: 1px solid var(--linha);
  font-family: 'DM Sans', sans-serif;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-cancel {
  background: transparent;
  color: var(--texto-dim);
}

.btn-cancel:active {
  background: var(--bg-card);
  color: var(--texto);
}

.btn-confirm {
  background: var(--acao);
  color: var(--bg);
  border-color: var(--acao);
  font-weight: 700;
}

.btn-confirm:active {
  background: var(--acao-hover);
  border-color: var(--acao-hover);
}

/* ---------- TYPING STATE ---------- */
.state-typing {
  justify-content: flex-start;
  padding-top: 40px;
}

.typing-card {
  background: var(--bg-card);
  border: 1px solid var(--linha);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
  text-align: left;
  width: 100%;
}

.typing-area {
  width: 100%;
  min-height: 140px;
  background: transparent;
  border: none;
  color: var(--texto);
  font-family: 'DM Sans', sans-serif;
  font-size: 16px;
  line-height: 1.45;
  resize: none;
  outline: none;
  padding: 0;
  -webkit-appearance: none;
  appearance: none;
  user-select: text;
  -webkit-user-select: text;
}

.typing-area::placeholder {
  color: var(--texto-faint);
  font-style: italic;
}

.typing-counter {
  margin-top: 12px;
  text-align: right;
  font-size: 11px;
  color: var(--texto-faint);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.3px;
}

.typing-counter.is-over {
  color: var(--erro);
}

/* ---------- SENDING / SPINNER ---------- */
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--linha);
  border-top-color: var(--acao);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 24px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---------- ERROR STATE ---------- */
.error-icon {
  font-family: 'Bungee', sans-serif;
  font-size: 56px;
  color: var(--erro);
  margin-bottom: 16px;
  line-height: 1;
}

.error-text {
  font-size: 15px;
  color: var(--texto-dim);
  margin-bottom: 24px;
  max-width: 240px;
  line-height: 1.4;
}

/* ---------- FOOTER ---------- */
.footer {
  padding: 16px 24px 28px;
  border-top: 1px solid var(--linha);
}

.footer-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--texto-faint);
  margin-bottom: 8px;
  font-weight: 500;
}

.footer-text {
  font-size: 13px;
  color: var(--texto);
  line-height: 1.45;
  opacity: 0.85;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.badge {
  display: inline-block;
  background: rgba(184, 149, 106, 0.1);
  color: var(--acento);
  border: 1px solid rgba(184, 149, 106, 0.25);
  font-size: 10px;
  padding: 3px 10px;
  border-radius: 4px;
  font-weight: 600;
  margin-top: 8px;
  letter-spacing: 0.3px;
}

/* ---------- TOAST ---------- */
.toast {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom) + 24px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card-2);
  color: var(--texto);
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--linha);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
  z-index: 100;
  animation: toastIn 0.3s ease;
  max-width: 90%;
  text-align: center;
}

.toast[hidden] { display: none; }

@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* Subtitle states */
.logo-sub.is-listening { color: var(--acao); }
.logo-sub.is-confirm   { color: var(--acento); }

/* Estado gravando do mic */
.mic-button.is-recording {
  background: #B85C5C;
  animation: recordingPulse 1.5s ease-in-out infinite;
}
@keyframes recordingPulse {
  0%, 100% { box-shadow: 0 8px 24px rgba(184, 92, 92, 0.3), 0 2px 6px rgba(0,0,0,0.3); }
  50% { box-shadow: 0 8px 32px rgba(184, 92, 92, 0.6), 0 2px 6px rgba(0,0,0,0.3); }
}

/* Debug line */
.debug-line {
  font-size: 10px;
  color: var(--texto-faint);
  font-family: monospace;
  margin-top: 8px;
  opacity: 0.5;
  min-height: 14px;
}

/* Live transcript visivel no estado idle quando gravando */
.live-transcript {
  margin-top: 24px;
  font-size: 14px;
  color: var(--texto-dim);
  font-style: italic;
  min-height: 20px;
  max-width: 280px;
  line-height: 1.4;
  text-align: center;
}

/* ---------- LOGIN / DENIED ---------- */
.state-login,
.state-denied {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
}

.btn-google {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 14px 22px;
  background: #fff;
  color: #1f1f1f;
  border: none;
  border-radius: 999px;
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.2px;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0,0,0,0.35), 0 1px 2px rgba(0,0,0,0.2);
  transition: transform 0.1s ease, box-shadow 0.2s ease;
}
.btn-google:hover { box-shadow: 0 8px 22px rgba(0,0,0,0.4), 0 1px 2px rgba(0,0,0,0.2); }
.btn-google:active { transform: scale(0.98); }

