/* ============================================================
   🎨 DEUTSCH B1 WEBAPP - SHARED STYLES
   Mobile-first responsive design
   ============================================================ */

:root {
  --primary: #1a73e8;
  --primary-light: #e8f0fe;
  --card-bg: #ffffff;
  --hover-bg: #f1f3f4;
  --primary-dark: #1557b0;
  --success: #34a853;
  --success-light: #e6f4ea;
  --warning: #f9ab00;
  --warning-light: #fef7e0;
  --error: #ea4335;
  --error-light: #fce8e6;
  --bg: #f8f9fa;
  --surface: #ffffff;
  --text: #202124;
  --text-secondary: #5f6368;
  --text-muted: #9aa0a6;
  --border: #dadce0;
  --border-light: #e8eaed;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.06), 0 1px 3px rgba(0,0,0,0.1);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  padding-bottom: 70px; /* Space for bottom tabs */
}

/* ===== NAVBAR ===== */
.navbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border-light);
  padding: 0 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}
.navbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  height: 56px;
  gap: 16px;
}
.navbar-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
  flex-shrink: 0;
}
.flag { width: 24px; height: 16px; border-radius: 2px; overflow: hidden; display: flex; flex-direction: column; }
.flag span { flex: 1; }
.flag .bk { background: #000; }
.flag .rd { background: #dd0000; }
.flag .gd { background: #ffcc00; }

.navbar-nav {
  display: flex;
  gap: 2px;
  list-style: none;
  flex-wrap: nowrap;
  overflow-x: auto;
  flex: 1;
}
.navbar-nav a {
  text-decoration: none;
  color: var(--text-secondary);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  transition: all 0.15s ease;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 4px;
}
.navbar-nav a:hover { background: var(--primary-light); color: var(--primary); }
.navbar-nav a.active { background: var(--primary); color: white; }

.hamburger {
  display: none;
  background: none;
  border: none;
  font-size: 20px;
  color: var(--text);
  cursor: pointer;
  padding: 8px;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  margin-left: auto;
}
.user-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.btn-logout {
  background: none;
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 13px;
  transition: all 0.15s;
}
.btn-logout:hover { color: var(--error); border-color: var(--error); }

/* ===== BOTTOM TABS (MOBILE) ===== */
.bottom-tabs {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: space-around;
  padding: 6px 0 env(safe-area-inset-bottom, 6px);
  z-index: 100;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.05);
}
.bottom-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
}
.bottom-tab i { font-size: 18px; }
.bottom-tab.active { color: var(--primary); }
.bottom-tab.active i { color: var(--primary); }

/* ===== CONTAINER ===== */
.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 24px 16px;
}

/* ===== CARDS ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  font-family: var(--font);
  transition: all 0.15s ease;
  text-decoration: none;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #2d9249; }
.btn-outline { background: transparent; border: 1.5px solid var(--border); color: var(--text-secondary); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 14px 28px; font-size: 16px; }
.btn-block { display: flex; width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== SECTION HEADERS ===== */
.section-header { margin-bottom: 20px; }
.section-title { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.section-desc { font-size: 14px; color: var(--text-secondary); }

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 24px;
  background: var(--success);
  color: white;
  border-radius: 100px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  display: none;
  z-index: 300;
  white-space: nowrap;
}
.toast.show {
  display: block;
  animation: pop 0.3s ease;
}
@keyframes pop { from { transform: translateX(-50%) scale(0.8); opacity:0; } to { transform: translateX(-50%) scale(1); opacity:1; } }

/* ===== LOADING ===== */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-muted);
  font-size: 14px;
}
.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border-light);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 10px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== PROGRESS BAR ===== */
.progress-bar {
  height: 8px;
  background: var(--border-light);
  border-radius: 100px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 100px;
  background: linear-gradient(90deg, var(--primary), #4fc3f7);
  transition: width 0.5s ease;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .navbar-nav {
    display: none;
    position: absolute;
    top: 56px;
    left: 0;
    right: 0;
    background: var(--surface);
    flex-direction: column;
    padding: 12px;
    border-bottom: 1px solid var(--border-light);
    box-shadow: var(--shadow-md);
  }
  .navbar-nav.show { display: flex; }
  .navbar-nav a { padding: 12px 16px; font-size: 14px; }
  .hamburger { display: block; }
  .user-name { display: none; }
}

@media (min-width: 769px) {
  .bottom-tabs { display: none; }
  body { padding-bottom: 0; }
}

/* ===== GENDER COLOR SYSTEM ===== */
.gender-maskulin {
  background: #e3f2fd !important;
  border-left: 4px solid #1976d2 !important;
}
.gender-feminin {
  background: #fce4ec !important;
  border-left: 4px solid #e91e63 !important;
}
.gender-neutrum {
  background: #e8f5e9 !important;
  border-left: 4px solid #4caf50 !important;
}
.gender-plural {
  background: #fff8e1 !important;
  border-left: 4px solid #ff8f00 !important;
}

.gender-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  font-size: 12px;
  font-weight: 500;
}
.gender-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}
.gender-dot {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}
.gender-dot.mask { background: #1976d2; }
.gender-dot.fem { background: #e91e63; }
.gender-dot.neut { background: #4caf50; }
.gender-dot.plur { background: #ff8f00; }

/* ===== SHADOWING PAGE ===== */
.shadow-sentence {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 12px;
}
.shadow-sentence .de-text {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}
.shadow-sentence .vi-text {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}
.shadow-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.shadow-controls .btn { font-size: 12px; padding: 6px 12px; }
.shadow-step {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 8px;
}
.recording-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--error);
  font-size: 12px;
  font-weight: 500;
}
.recording-indicator .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--error);
  animation: blink 1s infinite;
}
@keyframes blink { 0%,100%{opacity:1;} 50%{opacity:0.3;} }

/* ===== SELF-TALK SECTION ===== */
.selftalk-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin-top: 16px;
}
.selftalk-block {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 16px;
}
.selftalk-block h4 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 12px;
}
.selftalk-phrase {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-light);
}
.selftalk-phrase:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.selftalk-phrase .de { font-size: 14px; font-weight: 600; color: var(--text); }
.selftalk-phrase .vi { font-size: 12px; color: var(--text-secondary); }
.selftalk-phrase .btn-tts {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.15s;
}
.selftalk-phrase .btn-tts:hover { background: var(--primary); color: white; }


/* ===== DARK MODE ===== */
[data-theme="dark"] {
  --bg: #1a1a2e;
  --surface: #16213e;
  --card-bg: #16213e;
  --text: #e0e0e0;
  --text-secondary: #b0b0b0;
  --text-muted: #888888;
  --border: #2a2a4a;
  --border-light: #2a2a4a;
  --hover-bg: #1f2940;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 10px 20px rgba(0,0,0,0.5);
  --primary-light: #1a3a5c;
  --success-light: #1a3a2a;
  --warning-light: #3a3a1a;
  --error-light: #3a1a1a;
}
[data-theme="dark"] .navbar { background: #0f1a2e; border-color: #2a2a4a; }
[data-theme="dark"] .bottom-tabs { background: #0f1a2e; border-color: #2a2a4a; }
[data-theme="dark"] input,
[data-theme="dark"] textarea,
[data-theme="dark"] select { background: #1a2540; color: #e0e0e0; border-color: #2a2a4a; }
[data-theme="dark"] .btn-outline { color: #b0b0b0; border-color: #3a3a5a; }
[data-theme="dark"] .btn-outline:hover { background: #1f2940; }

/* Dark mode toggle button */
.dark-toggle {
  width: 32px; height: 32px; border-radius: 50%;
  border: 1px solid var(--border-light);
  background: transparent; color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 14px; transition: all 0.2s;
  margin-right: 8px;
}
.dark-toggle:hover { color: var(--primary); border-color: var(--primary); }
