/* ==========================================================================
   My English Flashcard - Design System & Modern Styling
   ========================================================================== */

:root {
  --bg-dark: #0b0f19;
  --bg-card: rgba(18, 24, 38, 0.85);
  --bg-card-hover: rgba(26, 34, 54, 0.95);
  --border-color: rgba(255, 255, 255, 0.1);
  --border-accent: rgba(56, 189, 248, 0.3);
  
  --primary-accent: #38bdf8;
  --primary-gradient: linear-gradient(135deg, #38bdf8 0%, #818cf8 100%);
  --secondary-gradient: linear-gradient(135deg, #f43f5e 0%, #fb923c 100%);
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  
  --badge-bg: rgba(56, 189, 248, 0.15);
  --badge-text: #38bdf8;
  
  --srs-hard: #f43f5e;
  --srs-good: #f59e0b;
  --srs-easy: #4ade80;
  
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;
  
  --transition-fast: 0.2s ease;
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --shadow-glow: 0 0 25px rgba(56, 189, 248, 0.15);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* Background Glow Orbs & Grid */
.bg-glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  z-index: -2;
  pointer-events: none;
}

.orb-1 {
  width: 450px;
  height: 450px;
  background: rgba(56, 189, 248, 0.12);
  top: -100px;
  left: -100px;
}

.orb-2 {
  width: 500px;
  height: 500px;
  background: rgba(129, 140, 248, 0.1);
  bottom: -150px;
  right: -150px;
}

.bg-grid {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-image: radial-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px);
  background-size: 32px 32px;
  z-index: -1;
  pointer-events: none;
}

/* Layout Container */
.app-container {
  max-width: 1560px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

/* App Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-color);
  flex-wrap: wrap;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo-icon {
  width: 48px;
  height: 48px;
  background: var(--primary-gradient);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: #fff;
  box-shadow: var(--shadow-glow);
}

.brand-text h1 {
  font-family: 'Outfit', sans-serif;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: linear-gradient(180deg, #ffffff 0%, #cbd5e1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.sub-badge {
  font-size: 13px;
  color: var(--primary-accent);
  font-weight: 500;
}

.header-stats {
  display: flex;
  align-items: center;
  gap: 16px;
}

.view-toggle-group {
  display: flex;
  background: rgba(255, 255, 255, 0.05);
  padding: 4px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.view-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  transition: var(--transition-fast);
  display: flex;
  align-items: center;
  gap: 6px;
}

.view-btn.active, .view-btn:hover {
  background: rgba(56, 189, 248, 0.2);
  color: #fff;
}

.stat-badge-group {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-card);
  padding: 8px 16px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
  font-size: 14px;
  font-weight: 600;
}

.stat-badge-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

#cloudSyncStatus {
  font-size: 13px;
  color: var(--text-muted);
}

#cloudSyncStatus.syncing {
  color: #FACC15;
}

#cloudSyncStatus.synced {
  color: #4ADE80;
}

#cloudSyncStatus.error {
  color: #F43F5E;
}

.stat-divider {
  width: 1px;
  height: 16px;
  background: var(--border-color);
}

/* Controls & Filter Section */
.controls-section {
  margin-bottom: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.controls-top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 280px;
}

.search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  font-size: 15px;
}

.search-box input {
  width: 100%;
  padding: 12px 16px 12px 44px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 14px;
  outline: none;
  transition: var(--transition-normal);
}

.search-box input:focus {
  border-color: var(--primary-accent);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15);
}

.page-size-selector {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-muted);
}

.page-size-selector select {
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  outline: none;
  cursor: pointer;
  font-size: 13px;
}

/* Filter Pills */
.filter-pills {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.pill {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 8px 16px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: var(--transition-fast);
  display: flex;
  align-items: center;
  gap: 6px;
}

.pill-badge {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  margin-left: 4px;
  transition: var(--transition-fast);
}

.pill:hover .pill-badge, .pill.active .pill-badge {
  background: rgba(56, 189, 248, 0.3);
  color: #fff;
}

.pill:hover, .pill.active {
  background: rgba(56, 189, 248, 0.15);
  border-color: var(--primary-accent);
  color: #fff;
}

.pill-divider {
  width: 1px;
  height: 24px;
  background: var(--border-color);
  align-self: center;
  margin: 0 4px;
}

/* Progress Indicator */
.progress-bar-container {
  margin-bottom: 24px;
}

.progress-info {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.progress-track {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--primary-gradient);
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
}

/* 6-Column Cards Grid */
.cards-grid-container {
  transition: var(--transition-normal);
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 16px;
}

@media (min-width: 1400px) {
  .cards-grid {
    grid-template-columns: repeat(6, 1fr);
  }
}

.grid-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 180px;
  cursor: pointer;
  transition: var(--transition-normal);
  position: relative;
  backdrop-filter: blur(10px);
}

.grid-card:hover {
  transform: translateY(-4px);
  border-color: var(--border-accent);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4), var(--shadow-glow);
}

.grid-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.grid-category {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--primary-accent);
  background: var(--badge-bg);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
}

.grid-srs-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.grid-srs-dot.srs-mastered { background-color: var(--srs-easy); }
.grid-srs-dot.srs-learning { background-color: var(--srs-good); }
.grid-srs-dot.srs-due { background-color: var(--srs-hard); }
.grid-srs-dot.srs-new { background-color: var(--primary-accent); }

.grid-card-term {
  font-family: 'Outfit', sans-serif;
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 4px;
  word-break: break-word;
}

.grid-card-ipa {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
  margin-bottom: 12px;
}

.grid-card-def {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.grid-card-bottom {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px dashed rgba(255, 255, 255, 0.08);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--text-dim);
}

/* Single 3D Focus Card Deck View */
.single-card-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  margin: 20px 0;
  transition: var(--transition-normal);
}

.single-card-container.hidden, .cards-grid-container.hidden {
  display: none !important;
}

.flashcard-scene {
  width: 100%;
  max-width: 680px;
  height: 380px;
  perspective: 1200px;
}

.flashcard-card {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
}

.flashcard-card.flipped {
  transform: rotateY(180deg);
}

.card-face {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  backdrop-filter: blur(16px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5);
}

/* Front Side */
.card-front {
  background: linear-gradient(145deg, rgba(18, 24, 38, 0.95), rgba(30, 41, 59, 0.85));
}

.card-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.category-badge {
  background: rgba(56, 189, 248, 0.15);
  color: var(--primary-accent);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 600;
}

.difficulty-badge {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 500;
}

.card-center {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin: auto 0;
}

.term-title {
  font-family: 'Outfit', sans-serif;
  font-size: 38px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: #fff;
}

.ipa-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ipa-text {
  font-size: 18px;
  color: var(--primary-accent);
  font-style: italic;
}

.audio-btn, .audio-btn-sm {
  background: rgba(56, 189, 248, 0.2);
  border: none;
  color: var(--primary-accent);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-fast);
}

.audio-btn:hover, .audio-btn-sm:hover {
  background: var(--primary-accent);
  color: #000;
  transform: scale(1.1);
}

.pos-tag {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  font-weight: 600;
}

.card-bottom-hint {
  text-align: center;
  font-size: 13px;
  color: var(--text-dim);
}

/* Back Side */
.card-back {
  transform: rotateY(180deg);
  background: linear-gradient(145deg, rgba(15, 23, 42, 0.95), rgba(24, 34, 52, 0.9));
}

.back-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--primary-accent);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-back-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin: auto 0;
  overflow-y: auto;
  padding-right: 4px;
  scrollbar-width: thin;
}

.def-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.def-block {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  padding: 12px 14px;
  border-radius: var(--radius-md);
}

.def-block h4 {
  font-size: 12px;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.def-block p {
  font-size: 14px;
  line-height: 1.5;
  color: #e2e8f0;
}

.workplace-context-block {
  background: rgba(56, 189, 248, 0.05);
  border-color: rgba(56, 189, 248, 0.2);
}

.workplace-context-block h4 {
  color: var(--primary-accent);
}

.memory-tip-block {
  background: rgba(250, 204, 21, 0.05);
  border-color: rgba(250, 204, 21, 0.2);
}

.memory-tip-block h4 {
  color: #facc15;
}

/* Action Controls & SRS Buttons */
.action-controls {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  max-width: 680px;
  justify-content: space-between;
}

.nav-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
  transition: var(--transition-fast);
}

.nav-btn:hover {
  background: rgba(56, 189, 248, 0.2);
  border-color: var(--primary-accent);
}

.srs-ratings {
  display: flex;
  gap: 12px;
  flex: 1;
  justify-content: center;
}

.srs-btn {
  flex: 1;
  max-width: 150px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #fff;
}

.btn-hard {
  background: rgba(244, 63, 94, 0.15);
  border-color: rgba(244, 63, 94, 0.4);
  color: #fda4af;
}

.btn-hard:hover {
  background: #f43f5e;
  color: #fff;
}

.btn-good {
  background: rgba(245, 158, 11, 0.15);
  border-color: rgba(245, 158, 11, 0.4);
  color: #fde68a;
}

.btn-good:hover {
  background: #f59e0b;
  color: #fff;
}

.btn-easy {
  background: rgba(74, 222, 128, 0.15);
  border-color: rgba(74, 222, 128, 0.4);
  color: #86efac;
}

.btn-easy:hover {
  background: #22c55e;
  color: #fff;
}

.deck-keyboard-hint {
  font-size: 12px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 6px;
}

kbd {
  background: rgba(255, 255, 255, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 11px;
}

/* Responsive Styles */
@media (max-width: 768px) {
  .app-header {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .def-grid {
    grid-template-columns: 1fr;
  }

  .flashcard-scene {
    height: 440px;
  }

  .term-title {
    font-size: 28px;
  }

  .desktop-text {
    display: none;
  }
}
