/* ============================================
   Filiatra Vokabeltrainer - Design System
   Mediterranean Warmth Theme
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* --- Design Tokens --- */
:root {
  --primary: #06B6D4; /* Türkis/Cyan */
  --primary-dark: #0891B2;
  --primary-light: #ECFEFF;
  --accent: #F59E0B;
  --accent-light: #FEF3C7;
  --success: #10B981;
  --success-light: #D1FAE5;
  --danger: #EF4444;
  --danger-light: #FEE2E2;
  --bg: #F0F9FF; /* Leichtes, frisches Blau-Weiß */
  --bg-card: #FFFFFF;
  --bg-dark: #1E293B;
  --text: #1E293B;
  --text-secondary: #475569;
  --text-muted: #94A3B8;
  --border: #E2E8F0;
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow: 0 4px 16px rgba(0,0,0,0.08);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.12);
  --shadow-card: 0 8px 32px rgba(37,99,235,0.10), 0 2px 8px rgba(0,0,0,0.06);
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { 
  font-size: 16px; 
  -webkit-text-size-adjust: 100%; 
  overscroll-behavior-y: none;
}
body {
  font-family: var(--font);
  background: #FFFFFF; /* Ensures Safari bottom bar is white */
  color: var(--text);
  line-height: 1.5;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

/* --- App Container --- */
#app {
  width: 100%;
  max-width: 430px;
  margin: 0 auto;
  min-height: 100dvh;
  position: relative;
  display: flex;
  flex-direction: column;
}

/* --- Views --- */
.view { display: none; flex-direction: column; min-height: 100dvh; }
.view.active { display: flex; }

/* ============================================
   Header
   ============================================ */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.app-header .logo-img {
  height: 44px; /* Deutlich größer */
  width: auto;
  display: block;
}
.app-header .level-badge {
  font-size: 12px;
  font-weight: 700;
  background: var(--primary-light);
  color: var(--primary);
  padding: 4px 10px;
  border-radius: 20px;
}

/* Menu Button */
.menu-btn {
  width: 40px;
  height: 40px;
  border: none;
  background: var(--bg);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  color: var(--text-secondary);
}
.menu-btn:hover { background: var(--primary-light); color: var(--primary); }
.menu-btn svg { width: 22px; height: 22px; }

/* ============================================
   Login View
   ============================================ */
.login-view {
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  background: url('../assets/login-bg.jpg') center/cover no-repeat;
}
.login-card {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 24px;
  padding: 40px 28px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}
.login-card .login-logo-img {
  height: 64px;
  width: auto;
  display: block;
  margin: 0 auto 8px auto;
}
.login-card .tagline {
  color: var(--text-muted);
  font-size: 15px;
  margin-bottom: 32px;
  font-weight: 500;
}
.login-card h2 {
  font-size: 20px;
  margin-bottom: 8px;
  color: var(--text);
}
.login-card p {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 24px;
}

/* Input */
.input-group {
  position: relative;
  margin-bottom: 16px;
}
.input-group input {
  width: 100%;
  padding: 14px 16px;
  font-size: 16px;
  font-family: var(--font);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: var(--transition);
  background: var(--bg);
  color: var(--text);
}
.input-group input:focus {
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(37,99,235,0.1);
}
.input-group input::placeholder { color: var(--text-muted); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 24px;
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  width: 100%;
}
.btn-primary {
  background: linear-gradient(135deg, var(--primary), #4F46E5);
  color: #fff;
  box-shadow: 0 4px 14px rgba(37,99,235,0.35);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(37,99,235,0.45);
}
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}
.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border: 2px solid var(--border);
}
.btn-secondary:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm {
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  min-height: auto;
}
.btn-success {
  background: linear-gradient(135deg, var(--success), #059669);
  color: #fff;
  box-shadow: 0 4px 14px rgba(16,185,129,0.35);
}

/* Email Sent State */
.email-sent-icon {
  width: 64px;
  height: 64px;
  background: var(--success-light);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  color: var(--success);
}
.email-sent-icon svg { width: 32px; height: 32px; }

/* ============================================
   Card Stack (Main Learning View)
   ============================================ */
.cards-view {
  background: #E0F2FE; /* Klares, sehr helles Himmelblau (Sky Blue) statt Grünlich */
  height: 100dvh;
  overflow: hidden;
}
.card-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  position: relative;
  min-height: 400px;
  overflow: hidden;
}

/* Card Stack */
.card-stack {
  position: relative;
  width: 100%;
  max-width: 340px;
  height: 420px;
}

/* Background cards for depth effect (entfernt auf User-Wunsch) */
.card-stack::before,
.card-stack::after {
  display: none;
}

/* Vocabulary Card */
.vocab-card {
  position: absolute;
  width: 100%;
  height: 100%;
  perspective: 1000px;
  cursor: grab;
  z-index: 2;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}
.vocab-card.dragging { cursor: grabbing; transition: none !important; }
.vocab-card.animating {
  transition: transform 0.4s cubic-bezier(0.2, 0, 0, 1),
              opacity 0.4s ease;
}

/* Make overlays fade out slowly when card snaps back */
.vocab-card.animating .swipe-overlay {
  transition: opacity 1s ease, transform 0.4s cubic-bezier(0.2, 0, 0, 1);
}

.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  transform-style: preserve-3d;
}
.vocab-card.flipped .card-inner { transform: rotateY(180deg); }

.card-front, .card-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: var(--radius);
  background: var(--bg-card);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  padding: 0; /* padding handled inside wrapper */
  overflow: hidden;
}
.card-front::before {
  display: none;
}
.card-back {
  transform: rotateY(180deg);
  background: linear-gradient(165deg, #075985, #0C4A6E); /* Freundliches Dunkelblau (Ocean Blue) */
  color: #fff;
}
.card-back::before {
  display: none;
}

/* Card Content Layout */
.card-top-bar {
  width: 100%;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(0,0,0,0.02);
  border-bottom: 1px solid var(--border);
  height: 48px;
}
.card-back .card-top-bar {
  background: rgba(255,255,255,0.05);
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.card-top-bar.empty {
  visibility: hidden;
}
.type-icon { font-size: 16px; }

.card-content-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 24px;
  width: 100%;
}

/* Card Content */
.card-word-type {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  margin-bottom: 0;
}
.card-back .card-word-type { color: rgba(255,255,255,0.5); }

.card-word {
  font-size: 32px;
  font-weight: 700;
  text-align: center;
  line-height: 1.3;
  margin-bottom: 8px;
}
.card-transliteration {
  font-size: 16px;
  color: rgba(255,255,255,0.6);
  font-style: italic;
  margin-bottom: 16px;
}
.card-gender {
  font-size: 13px;
  padding: 4px 12px;
  border-radius: 20px;
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}
.card-back .card-gender {
  background: rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.9);
}

/* Conjugation Table */
.card-conjugation {
  width: 100%;
  margin-top: 16px;
  font-size: 13px;
}
.card-conjugation table {
  width: 100%;
  border-collapse: collapse;
}
.card-conjugation td {
  padding: 4px 8px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.card-conjugation td:first-child {
  color: rgba(255,255,255,0.5);
  font-size: 12px;
  width: 40%;
}

/* Swipe Feedback Overlays */
.swipe-overlay {
  position: absolute;
  top: 24px;
  padding: 8px 20px;
  border-radius: var(--radius-sm);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 2px;
  opacity: 0;
  transform: scale(0.8);
  transition: opacity 0.15s, transform 0.15s;
  z-index: 10;
  text-transform: uppercase;
}
.swipe-overlay.like {
  right: 24px;
  border: 3px solid var(--success);
  color: var(--success);
  transform: rotate(12deg) scale(0.8);
}
.swipe-overlay.nope {
  left: 24px;
  border: 3px solid var(--danger);
  color: var(--danger);
  transform: rotate(-12deg) scale(0.8);
}
.swipe-overlay.visible {
  opacity: 1;
  transform: rotate(12deg) scale(1);
}
.swipe-overlay.nope.visible { transform: rotate(-12deg) scale(1); }

/* Tap hint */
.card-tap-hint {
  position: absolute;
  bottom: 20px;
  left: 0;
  width: 100%;
  justify-content: center;
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}
.card-back .card-tap-hint { color: rgba(255,255,255,0.4); }

/* ============================================
   Bottom Controls
   ============================================ */
.card-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 20px;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
}
.control-btn {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: var(--shadow);
}
.control-btn svg { width: 28px; height: 28px; }
.control-btn.nope-btn {
  background: #fff;
  color: var(--danger);
  border: 2px solid var(--danger-light);
}
.control-btn.nope-btn:hover {
  background: var(--danger);
  color: #fff;
  transform: scale(1.08);
}
.control-btn.like-btn {
  background: #fff;
  color: var(--success);
  border: 2px solid var(--success-light);
}
.control-btn.like-btn:hover {
  background: var(--success);
  color: #fff;
  transform: scale(1.08);
}
.control-btn.undo-btn {
  width: 44px;
  height: 44px;
  background: var(--bg);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.control-btn.undo-btn:hover { color: var(--primary); border-color: var(--primary-light); }
.control-btn.undo-btn svg { width: 20px; height: 20px; }

/* Progress Bar */
.progress-bar-container {
  padding: 0 20px;
  background: var(--bg-card);
}
.progress-info {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 500;
}
.progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 4px;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #7C3AED);
  border-radius: 3px;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================
   Stats / Session Complete View
   ============================================ */
.stats-view {
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: url('../assets/login-bg.jpg') center/cover no-repeat;
}
.stats-card {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 24px;
  padding: 36px 28px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}
.stats-card h2 { font-size: 22px; margin-bottom: 4px; }
.stats-card .stats-subtitle { color: var(--text-muted); font-size: 14px; margin-bottom: 28px; }

/* Donut Chart */
.donut-chart {
  width: 160px;
  height: 160px;
  margin: 0 auto 24px;
  position: relative;
}
.donut-chart svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.donut-chart circle {
  fill: none;
  stroke-width: 12;
  stroke-linecap: round;
}
.donut-bg { stroke: var(--border); }
.donut-correct { stroke: var(--success); transition: stroke-dasharray 1s ease; }
.donut-incorrect { stroke: var(--danger); transition: stroke-dasharray 1s ease; }
.donut-label {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}
.donut-label .percentage { font-size: 36px; font-weight: 800; color: var(--text); }
.donut-label .label-text { font-size: 12px; color: var(--text-muted); }

/* Stat Rows */
.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.stat-row:last-child { border-bottom: none; }
.stat-row .stat-label { color: var(--text-secondary); display: flex; align-items: center; gap: 8px; }
.stat-row .stat-value { font-weight: 700; }
.stat-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.stat-dot.correct { background: var(--success); }
.stat-dot.incorrect { background: var(--danger); }
.stat-dot.seen { background: var(--primary); }
.stat-dot.learned { background: var(--accent); }

.stats-actions { margin-top: 24px; display: flex; flex-direction: column; gap: 10px; }

/* ============================================
   Menu / Settings View
   ============================================ */
.menu-view {
  padding: 0;
  background: var(--bg);
}
.menu-header {
  background: linear-gradient(135deg, var(--primary), #7C3AED);
  padding: 32px 24px;
  color: #fff;
  text-align: center;
}
.menu-header .user-avatar {
  width: 56px;
  height: 56px;
  background: rgba(255,255,255,0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
  font-size: 24px;
  font-weight: 700;
}
.menu-header .user-email { font-size: 14px; opacity: 0.85; }

.menu-section {
  padding: 20px;
}
.menu-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  margin-bottom: 10px;
  padding: 0 4px;
}
.menu-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid transparent;
  font-size: 15px;
  color: var(--text);
}
.menu-item:hover { border-color: var(--primary-light); background: #FAFBFF; }
.menu-item.active { border-color: var(--primary); background: var(--primary-light); }
.menu-item .menu-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.menu-item .menu-icon.blue { background: var(--primary-light); color: var(--primary); }
.menu-item .menu-icon.amber { background: var(--accent-light); color: var(--accent); }
.menu-item .menu-icon.green { background: var(--success-light); color: var(--success); }
.menu-item .menu-icon.red { background: var(--danger-light); color: var(--danger); }
.menu-item .menu-label { flex: 1; font-weight: 500; }
.menu-item .menu-value { font-size: 13px; color: var(--text-muted); font-weight: 600; }
.menu-item .menu-chevron { color: var(--text-muted); font-size: 18px; }

/* Back button */
.back-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  background: none;
  border: none;
  color: #fff;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  position: absolute;
  top: 16px;
  left: 8px;
}
.back-btn svg { width: 20px; height: 20px; }

/* ============================================
   Select Dropdown (Level/Language)
   ============================================ */
.select-group { margin-bottom: 16px; }
.select-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.select-group select {
  width: 100%;
  padding: 12px 16px;
  font-size: 15px;
  font-family: var(--font);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  outline: none;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M4.5 6l3.5 4 3.5-4z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
.select-group select:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(37,99,235,0.1); }

/* ============================================
   Loading & Feedback
   ============================================ */
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--bg-dark);
  color: #fff;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
}
.toast.visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 48px 24px;
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 16px; }
.empty-state h3 { font-size: 18px; margin-bottom: 8px; }
.empty-state p { color: var(--text-muted); font-size: 14px; margin-bottom: 24px; }

/* ============================================
   Animations
   ============================================ */
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideUp { from { opacity: 0; transform: translateY(30px); } to { opacity: 1; transform: translateY(0); } }
@keyframes popIn { from { opacity: 0; transform: scale(0.9); } to { opacity: 1; transform: scale(1); } }
.animate-in { animation: fadeIn 0.4s ease forwards; }
.animate-slide { animation: slideUp 0.5s ease forwards; }
.animate-pop { animation: popIn 0.3s ease forwards; }

/* Stagger children */
.stagger > *:nth-child(1) { animation-delay: 0s; }
.stagger > *:nth-child(2) { animation-delay: 0.05s; }
.stagger > *:nth-child(3) { animation-delay: 0.1s; }
.stagger > *:nth-child(4) { animation-delay: 0.15s; }
.stagger > *:nth-child(5) { animation-delay: 0.2s; }

/* ============================================
   Responsive (Tablet/Desktop optional)
   ============================================ */
@media (min-width: 768px) {
  body {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(165deg, #EEF2FF 0%, #F0F4FA 40%, #DBEAFE 100%);
    overflow: hidden; /* Prevent body scroll on desktop */
  }
  #app {
    max-width: 430px;
    height: 90vh;
    min-height: 650px;
    max-height: 900px;
    border-radius: 24px;
    overflow-y: auto; /* Allow internal scrolling if needed */
    overflow-x: hidden;
    box-shadow: var(--shadow-lg);
    margin: 0;
  }
  .view {
    min-height: 100%; /* Override 100dvh for desktop */
  }
  .cards-view {
    height: 100%; /* Override 100dvh for desktop */
  }
}
}
