/* =============================================
   SpeakOS App Styles
   ============================================= */

/* === SCENARIOS PAGE === */
.scenarios-page {
  max-width: 680px;
  margin: 0 auto;
  padding: var(--space-lg) var(--pad);
  min-height: calc(100vh - 65px);
}

.back-link {
  margin-bottom: var(--space-lg);
}
.back-link a {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--fg-muted);
  text-decoration: none;
  transition: color 0.15s;
}
.back-link a:hover { color: var(--fg); }

.page-title-group { margin-bottom: var(--space-xl); }
.page-title {
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 3.5vw, 2.5rem);
  font-weight: 700;
  color: var(--fg);
  letter-spacing: -0.02em;
  margin: 0.5rem 0;
}
.page-sub {
  color: var(--fg-muted);
  font-size: 1rem;
  line-height: 1.6;
}

.scenario-cards {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.scenario-card {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-lg);
  background: var(--surface);
  text-decoration: none;
  transition: background 0.15s;
  cursor: pointer;
}
.scenario-card:hover { background: #F8F6F1; }

.scenario-icon {
  font-size: 1.75rem;
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.scenario-info { flex: 1; }
.scenario-name {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--fg);
  margin-bottom: 0.25rem;
}
.scenario-desc {
  font-size: 0.875rem;
  color: var(--fg-muted);
}

.scenario-arrow {
  font-size: 1.25rem;
  color: var(--fg-muted);
  flex-shrink: 0;
}

/* === CHAT PAGE === */
.chat-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: 0.875rem var(--pad);
  border-bottom: 1px solid var(--border);
  background: rgba(250, 248, 245, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 10;
  flex-shrink: 0;
}

.back-btn {
  font-size: 1.125rem;
  color: var(--fg-muted);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.15s;
  flex-shrink: 0;
}
.back-btn:hover { color: var(--fg); }

.chat-scenario-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  color: var(--fg);
  font-size: 0.95rem;
}
.scenario-emoji { font-size: 1.25rem; }

.recording-indicator {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: #D63B3B;
}
.rec-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #D63B3B;
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.85); }
}

/* Messages */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-lg) var(--pad);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.welcome-message {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  max-width: 520px;
  align-self: center;
  text-align: center;
  margin: auto 0;
}
.welcome-icon { font-size: 2.5rem; margin-bottom: 0.75rem; }
.welcome-message p { font-size: 0.95rem; color: var(--fg); line-height: 1.6; }
.welcome-message strong { font-weight: 600; }
.welcome-message .tip {
  font-size: 0.85rem;
  color: var(--fg-muted);
  margin-top: 0.5rem;
}

.message {
  max-width: 520px;
  border-radius: var(--radius-md);
  padding: 0.875rem 1.125rem;
  font-size: 0.95rem;
  line-height: 1.55;
  animation: msg-in 0.2s ease;
}
@keyframes msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.message-user {
  background: #EAF0FF;
  border: 1px solid #C8D5F5;
  align-self: flex-end;
  color: var(--fg);
}
.message-assistant {
  background: var(--surface);
  border: 1.5px solid var(--border);
  align-self: flex-start;
  color: var(--fg);
}
.message-user .msg-label { display: none; }
.msg-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--fg-muted);
  margin-bottom: 0.35rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* Pronunciation bar */
.pronunciation-bar {
  padding: 0.75rem var(--pad);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  flex-shrink: 0;
}
.pronunciation-score {
  font-weight: 700;
  font-size: 1.5rem;
  color: var(--fg);
  min-width: 52px;
}
.pronunciation-score::after { content: '%'; font-size: 1rem; }
.pronunciation-feedback {
  font-size: 0.875rem;
  color: var(--fg-muted);
}

/* Input area */
.chat-input-area {
  padding: var(--space-sm) var(--pad);
  border-top: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}
.input-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.chat-input {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--fg);
  background: var(--surface);
  outline: none;
  transition: border-color 0.15s;
}
.chat-input:focus { border-color: var(--accent); }
.chat-input::placeholder { color: var(--fg-muted); }

.mic-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg-deep);
  color: white;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s, background 0.15s;
  flex-shrink: 0;
}
.mic-btn:hover { background: #253a5e; transform: scale(1.05); }
.mic-btn.recording {
  background: #D63B3B;
  animation: mic-pulse 1s ease-in-out infinite;
}
@keyframes mic-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

.send-btn {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: white;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
  flex-shrink: 0;
}
.send-btn:hover { background: var(--accent-2); transform: scale(1.05); }

.tts-toggle {
  padding: 0.4rem var(--pad) 0;
  display: flex;
  align-items: center;
}
.tts-toggle label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--fg-muted);
  cursor: pointer;
}
.tts-toggle input[type="checkbox"] { accent-color: var(--accent); }

/* Loading typing indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0.875rem 1.125rem;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  align-self: flex-start;
}
.typing-dot {
  width: 6px;
  height: 6px;
  background: var(--fg-muted);
  border-radius: 50%;
  animation: typing-bounce 1.2s ease-in-out infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.15s; }
.typing-dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-4px); }
}

/* Mobile responsive */
@media (max-width: 480px) {
  .chat-header { padding: 0.75rem 1rem; }
  .chat-messages { padding: 1rem; }
  .pronunciation-bar { padding: 0.6rem 1rem; }
  .chat-input-area { padding: 0.6rem 1rem; }
  .message { max-width: 100%; font-size: 0.9rem; }
  .welcome-message { padding: 1.25rem; }
}