/* ==========================================================================
   DosIdiomas: Design System & Mobile-First Styling für Google Pixel 9a
   ========================================================================== */

:root {
  --bg-main: #0b0f19;
  --bg-card: #151d2d;
  --bg-card-elevated: #1e293b;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-active: rgba(16, 185, 129, 0.3);

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --accent-emerald: #10b981;
  --accent-emerald-glow: rgba(16, 185, 129, 0.2);
  --accent-fire: #f59e0b;
  --accent-blue: #0ea5e9;
  --accent-danger: #ef4444;

  --nav-height: 68px;
  --header-height: 60px;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-pill: 9999px;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  user-select: none;
}

/* ==========================================================================
   HEADER
   ========================================================================== */

.app-header {
  height: var(--header-height);
  background: rgba(11, 15, 25, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  font-size: 1.5rem;
}

.logo-text {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #10b981, #38bdf8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.header-badges {
  display: flex;
  align-items: center;
  gap: 10px;
}

.streak-pill {
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: var(--accent-fire);
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  font-size: 0.85rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 4px;
}

.status-pill {
  font-size: 0.75rem;
  padding: 4px 8px;
  border-radius: var(--radius-pill);
  font-weight: 600;
}

.status-pill.online {
  background: rgba(16, 185, 129, 0.12);
  color: var(--accent-emerald);
}

.status-pill.offline {
  background: rgba(239, 68, 68, 0.15);
  color: var(--accent-danger);
}

/* ==========================================================================
   APP CONTENT & TABS
   ========================================================================== */

.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(var(--nav-height) + 12px);
}

.tab-content {
  display: none;
  flex-direction: column;
  flex: 1;
  padding: 16px;
  max-width: 600px;
  margin: 0 auto;
  width: 100%;
}

.tab-content.active {
  display: flex;
}

/* ==========================================================================
   CHAT / CONVERSACIONES
   ========================================================================== */

.scenario-bar {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  margin-bottom: 12px;
}

.scenario-select {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 0.95rem;
  font-weight: 600;
  outline: none;
  cursor: pointer;
}

.scenario-select option {
  background: var(--bg-card);
  color: var(--text-primary);
}

.scenario-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
  line-height: 1.3;
}

.chat-stream {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-bottom: 12px;
  min-height: 300px;
}

.chat-bubble {
  max-width: 92%;
  border-radius: var(--radius-md);
  padding: 14px 16px;
  line-height: 1.45;
  font-size: 0.95rem;
  animation: fadeIn 0.25s ease-out;
}

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

.user-bubble {
  align-self: flex-end;
  background: linear-gradient(135deg, #059669, #10b981);
  color: white;
  border-bottom-right-radius: 4px;
  font-weight: 500;
}

.assistant-bubble {
  align-self: flex-start;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-bottom-left-radius: 4px;
}

.system-bubble {
  align-self: center;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
}

/* Tap to Translate Words */
.spanish-text {
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 8px;
  line-height: 1.6;
}

.tap-word {
  cursor: pointer;
  border-bottom: 1px dotted rgba(16, 185, 129, 0.5);
  transition: all 0.15s ease;
  display: inline-block;
  padding: 0 1px;
}

.tap-word:active, .tap-word.tapped {
  background: var(--accent-emerald-glow);
  color: #34d399;
  border-radius: 4px;
}

/* Audio Controls */
.audio-controls {
  display: flex;
  gap: 8px;
  margin: 10px 0;
}

.audio-btn {
  background: var(--bg-card-elevated);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.audio-btn:active {
  background: rgba(255, 255, 255, 0.1);
}

/* Spoiler Accordions */
.spoiler-accordion {
  margin-top: 8px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.spoiler-accordion summary {
  padding: 8px 12px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.spoiler-accordion summary::-webkit-details-marker {
  display: none;
}

.spoiler-accordion summary::after {
  content: "▼";
  font-size: 0.65rem;
  transition: transform 0.2s;
}

.spoiler-accordion[open] summary::after {
  transform: rotate(180deg);
}

.spoiler-content {
  padding: 10px 12px;
  border-top: 1px solid var(--border-color);
  font-size: 0.88rem;
  color: #cbd5e1;
  line-height: 1.4;
}

/* Floating Push-to-Talk Footer */
.chat-footer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: auto;
}

.text-input-row {
  display: flex;
  gap: 8px;
}

.chat-input {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-pill);
  padding: 12px 18px;
  color: white;
  font-size: 0.95rem;
  outline: none;
}

.chat-input:focus {
  border-color: var(--accent-emerald);
}

.send-btn {
  background: var(--bg-card-elevated);
  border: 1px solid var(--border-color);
  color: white;
  width: 46px;
  height: 46px;
  border-radius: var(--radius-pill);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.ptt-btn {
  width: 100%;
  height: 52px;
  background: linear-gradient(135deg, #10b981, #059669);
  border: none;
  border-radius: var(--radius-pill);
  color: white;
  font-size: 1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35);
  transition: all 0.2s;
}

.ptt-btn.recording {
  background: #ef4444;
  box-shadow: 0 0 20px rgba(239, 68, 68, 0.7);
  animation: pulse 1.2s infinite;
}

@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.03); }
  100% { transform: scale(1); }
}

.end-session-row {
  display: flex;
  justify-content: center;
  margin-top: 4px;
}

.end-session-btn {
  background: transparent;
  border: 1px dashed var(--border-color);
  color: var(--text-muted);
  padding: 6px 16px;
  border-radius: var(--radius-pill);
  font-size: 0.78rem;
  cursor: pointer;
}

/* ==========================================================================
   TAP TOOLTIP
   ========================================================================== */

#tap-tooltip {
  position: absolute;
  background: #1e293b;
  border: 1px solid var(--accent-emerald);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  color: white;
  z-index: 9999;
  display: none;
  animation: popIn 0.15s ease-out;
}

#tap-tooltip.visible {
  display: block;
}

@keyframes popIn {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.badge-saved {
  display: inline-block;
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 6px;
}

/* ==========================================================================
   VOKABELTRAINER (SRS FLASHCARD)
   ========================================================================== */

.srs-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  gap: 20px;
}

.progress-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.flashcard {
  width: 100%;
  min-height: 280px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: transform 0.2s, border-color 0.2s;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.flashcard:active {
  transform: scale(0.98);
}

.card-word-es {
  font-size: 2rem;
  font-weight: 800;
  color: #38bdf8;
  margin-bottom: 12px;
}

.card-context {
  font-size: 0.95rem;
  color: var(--text-secondary);
  font-style: italic;
  max-width: 90%;
  line-height: 1.4;
}

.card-word-de {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--accent-emerald);
  margin-top: 16px;
  display: none;
}

.flashcard.flipped .card-word-de {
  display: block;
}

.flip-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 16px;
}

/* Voice Preview Actions */
.voice-preview-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(30, 41, 59, 0.9);
  border: 1px solid var(--accent-emerald);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  animation: fadeIn 0.2s ease-out;
}

.voice-preview-label {
  font-size: 0.8rem;
  color: #94a3b8;
  font-weight: 600;
}

.voice-btn-group {
  display: flex;
  gap: 8px;
}

.voice-confirm-btn {
  background: var(--accent-emerald);
  border: none;
  color: white;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}

.voice-cancel-btn {
  background: rgba(239, 68, 68, 0.2);
  border: 1px solid var(--accent-danger);
  color: #f87171;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}

/* ==========================================================================
   VOKABELTRAINER (AKTIVES EINGABEFELD)
   ========================================================================== */

.card-prompt-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.card-word-prompt {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--accent-emerald);
  margin-bottom: 12px;
}

.srs-input-row {
  display: flex;
  gap: 8px;
  width: 100%;
}

.srs-input {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  color: white;
  font-size: 1.05rem;
  outline: none;
  font-weight: 600;
}

.srs-input:focus {
  border-color: var(--accent-emerald);
  box-shadow: 0 0 0 2px var(--accent-emerald-glow);
}

.srs-submit-btn {
  padding: 0 24px;
  border-radius: var(--radius-md);
}

/* ==========================================================================
   GRAMMATIK & LÜCKENTEXT-TRAINER
   ========================================================================== */

.grammar-wrapper {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
}

.grammar-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.sentence-container {
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.6;
  margin-bottom: 24px;
  color: var(--text-primary);
}

.blank-slot {
  display: inline-block;
  min-width: 80px;
  border-bottom: 2px solid var(--accent-blue);
  color: var(--accent-blue);
  text-align: center;
  padding: 0 4px;
  font-weight: 700;
}

.blank-slot.correct-blank {
  color: var(--accent-emerald);
  border-color: var(--accent-emerald);
}

.blank-slot.wrong-blank {
  color: var(--accent-danger);
  border-color: var(--accent-danger);
}

.options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.grammar-opt-btn {
  background: var(--bg-card-elevated);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 16px;
  border-radius: var(--radius-md);
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}

.grammar-opt-btn:active {
  transform: scale(0.97);
}

.grammar-opt-btn.correct {
  background: rgba(16, 185, 129, 0.25);
  border-color: var(--accent-emerald);
  color: #34d399;
}

.grammar-opt-btn.wrong {
  background: rgba(239, 68, 68, 0.25);
  border-color: var(--accent-danger);
  color: #f87171;
}

.feedback-box {
  border-radius: var(--radius-md);
  padding: 14px 16px;
  font-size: 0.9rem;
  line-height: 1.4;
  display: none;
}

.feedback-box.success {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #a7f3d0;
}

.feedback-box.error {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fecaca;
}

.primary-btn {
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  border: none;
  padding: 14px 24px;
  border-radius: var(--radius-pill);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35);
}

/* ==========================================================================
   STATISTIKEN & STREAK
   ========================================================================== */

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 12px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stat-value {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--text-primary);
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.stat-card.hero-card {
  grid-column: span 2;
  background: linear-gradient(135deg, #1e293b, #0f172a);
  border-color: rgba(245, 158, 11, 0.3);
}

.stat-card.hero-card .stat-value {
  color: var(--accent-fire);
}

/* ==========================================================================
   BOTTOM NAVIGATION (Thumb-friendly für Pixel 9a)
   ========================================================================== */

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: rgba(11, 15, 25, 0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom);
}

.nav-item {
  background: transparent;
  border: none;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  padding: 8px 12px;
  transition: all 0.15s;
}

.nav-icon {
  font-size: 1.25rem;
}

.nav-item.active {
  color: var(--accent-emerald);
}

.completion-box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 30px 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

/* Scenario Bar Enhancements */
.scenario-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.custom-prompt-btn {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: var(--accent-emerald);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.custom-prompt-btn:hover {
  background: rgba(16, 185, 129, 0.25);
}

/* Modal Overlay & Card */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}

.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
}

.modal-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.modal-title-row h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.close-btn {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
}

.modal-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 12px;
  line-height: 1.4;
}

.modal-input {
  width: 100%;
  background: var(--bg-dark);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  padding: 12px;
  font-size: 0.95rem;
  resize: vertical;
  outline: none;
  margin-bottom: 14px;
  box-sizing: border-box;
}

.modal-input:focus {
  border-color: var(--accent-emerald);
}

.modal-btn-row {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.secondary-btn {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  cursor: pointer;
}

/* Grammar Level Selector */
.level-selector-row {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  justify-content: center;
}

.level-pill {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 8px 10px;
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
}

.level-pill.active {
  background: rgba(16, 185, 129, 0.15);
  border-color: var(--accent-emerald);
  color: var(--accent-emerald);
  font-weight: 700;
}

/* Adaptive Level Recommendation Banner */
.adaptive-banner {
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.4);
  color: #93c5fd;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  line-height: 1.4;
  margin-bottom: 14px;
  animation: fadeIn 0.25s ease-out;
}

.banner-action-btn {
  background: #2563eb;
  color: white;
  border: none;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  margin-left: 6px;
  margin-top: 4px;
  display: inline-block;
}

.feedback-context {
  margin-top: 10px;
  font-size: 0.85rem;
  opacity: 0.9;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  padding-top: 8px;
}
