/* MelodLingo - Main CSS Design System */

/* ===== CSS Variables ===== */
:root {
  /* Primary Colors - Purple/Blue Gradient Theme */
  --primary-purple: #7C3AED;
  --primary-blue: #3B82F6;
  --primary-gradient: linear-gradient(135deg, #7C3AED 0%, #3B82F6 100%);
  --primary-gradient-hover: linear-gradient(135deg, #6D28D9 0%, #2563EB 100%);

  /* Secondary Colors */
  --secondary-pink: #EC4899;
  --secondary-teal: #14B8A6;
  --secondary-orange: #F59E0B;

  /* Neutral Colors */
  --white: #FFFFFF;
  --gray-50: #F9FAFB;
  --gray-100: #F3F4F6;
  --gray-200: #E5E7EB;
  --gray-300: #D1D5DB;
  --gray-400: #9CA3AF;
  --gray-500: #6B7280;
  --gray-600: #4B5563;
  --gray-700: #374151;
  --gray-800: #1F2937;
  --gray-900: #111827;
  --black: #000000;

  /* Semantic Colors */
  --success: #10B981;
  --warning: #F59E0B;
  --error: #EF4444;
  --info: #3B82F6;

  /* CEFR Level Colors */
  --level-a1: #10B981;
  --level-a2: #34D399;
  --level-b1: #3B82F6;
  --level-b2: #6366F1;
  --level-c1: #8B5CF6;
  --level-c2: #7C3AED;

  /* Typography */
  --font-primary: 'Segoe UI', 'Roboto', 'Helvetica Neue', sans-serif;
  --font-hebrew: 'Segoe UI', 'Arial Hebrew', 'Noto Sans Hebrew', sans-serif;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  --space-3xl: 64px;

  /* Border Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.15);
  --shadow-glow: 0 0 20px rgba(124, 58, 237, 0.3);

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-normal: 300ms ease;
  --transition-slow: 500ms ease;
}

/* ===== Reset & Base ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-primary);
  background: var(--gray-900);
  color: var(--white);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Hebrew text direction */
[dir="rtl"], .hebrew {
  direction: rtl;
  font-family: var(--font-hebrew);
}

/* ===== Typography ===== */
h1 {
  font-size: 2.5rem;
  font-weight: 700;
  line-height: 1.2;
}

h2 {
  font-size: 2rem;
  font-weight: 600;
  line-height: 1.3;
}

h3 {
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.4;
}

h4 {
  font-size: 1.25rem;
  font-weight: 500;
}

p {
  margin-bottom: var(--space-md);
}

a {
  color: var(--primary-blue);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--primary-purple);
}

/* ===== Layout ===== */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-md);
}

.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.page-content {
  flex: 1;
  padding: var(--space-lg);
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-lg);
  font-size: 1rem;
  font-weight: 500;
  border: none;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
}

.btn-primary {
  background: var(--primary-gradient);
  color: var(--white);
  box-shadow: var(--shadow-md);
}

.btn-primary:hover {
  background: var(--primary-gradient-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.btn-secondary {
  background: var(--gray-700);
  color: var(--white);
}

.btn-secondary:hover {
  background: var(--gray-600);
}

.btn-outline {
  background: transparent;
  border: 2px solid var(--primary-purple);
  color: var(--primary-purple);
}

.btn-outline:hover {
  background: var(--primary-purple);
  color: var(--white);
}

.btn-lg {
  padding: var(--space-md) var(--space-xl);
  font-size: 1.125rem;
}

.btn-sm {
  padding: var(--space-xs) var(--space-md);
  font-size: 0.875rem;
}

.btn-icon {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: var(--radius-full);
}

/* ===== Cards ===== */
.card {
  background: var(--gray-800);
  border-radius: var(--radius-xl);
  padding: var(--space-lg);
  box-shadow: var(--shadow-md);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.card-clickable {
  cursor: pointer;
}

/* ===== Inputs ===== */
.input {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  font-size: 1rem;
  background: var(--gray-700);
  border: 2px solid var(--gray-600);
  border-radius: var(--radius-md);
  color: var(--white);
  transition: border-color var(--transition-fast);
}

.input:focus {
  outline: none;
  border-color: var(--primary-purple);
}

.input::placeholder {
  color: var(--gray-400);
}

/* ===== Badges ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: var(--space-xs) var(--space-sm);
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: var(--radius-full);
  text-transform: uppercase;
}

.badge-a1 { background: var(--level-a1); color: var(--white); }
.badge-a2 { background: var(--level-a2); color: var(--gray-900); }
.badge-b1 { background: var(--level-b1); color: var(--white); }
.badge-b2 { background: var(--level-b2); color: var(--white); }
.badge-c1 { background: var(--level-c1); color: var(--white); }
.badge-c2 { background: var(--level-c2); color: var(--white); }

/* ===== Header/Navigation ===== */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  background: rgba(31, 41, 55, 0.95);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid var(--gray-700);
}

.header-logo {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--white);
}

.header-logo img, .header-logo svg {
  width: 40px;
  height: 40px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

/* ===== Bottom Navigation ===== */
.bottom-nav {
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: var(--space-sm) 0;
  background: var(--gray-800);
  border-top: 1px solid var(--gray-700);
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-sm);
  color: var(--gray-400);
  text-decoration: none;
  font-size: 0.75rem;
  transition: color var(--transition-fast);
}

.nav-item:hover, .nav-item.active {
  color: var(--primary-purple);
}

.nav-item svg {
  width: 24px;
  height: 24px;
}

/* ===== Genre Pills ===== */
.genre-bar {
  display: flex;
  gap: var(--space-sm);
  padding: var(--space-md) 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.genre-bar::-webkit-scrollbar {
  display: none;
}

.genre-pill {
  padding: var(--space-sm) var(--space-md);
  background: var(--gray-700);
  border-radius: var(--radius-full);
  font-size: 0.875rem;
  white-space: nowrap;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: none;
  color: var(--white);
}

.genre-pill:hover, .genre-pill.active {
  background: var(--primary-gradient);
}

/* ===== Songs Grid ===== */
.songs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: var(--space-md);
  padding-bottom: 80px;
}

.song-card {
  background: var(--gray-800);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.song-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-glow);
}

.song-card-image {
  width: 100%;
  aspect-ratio: 1;
  background: var(--primary-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  position: relative;
}

.song-card-image .play-icon {
  position: absolute;
  width: 48px;
  height: 48px;
  background: rgba(0, 0, 0, 0.7);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.song-card:hover .play-icon {
  opacity: 1;
}

.song-card-content {
  padding: var(--space-sm);
}

.song-card-title {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: var(--space-xs);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.song-card-artist {
  font-size: 0.8rem;
  color: var(--gray-400);
  margin-bottom: var(--space-xs);
}

/* ===== Lyrics Display ===== */
.lyrics-container {
  padding: var(--space-lg);
  max-width: 800px;
  margin: 0 auto;
}

.lyrics-line {
  padding: var(--space-md) 0;
  font-size: 1.25rem;
  line-height: 1.8;
  border-bottom: 1px solid var(--gray-700);
  transition: background var(--transition-fast);
}

.lyrics-line.active {
  background: rgba(124, 58, 237, 0.1);
  border-radius: var(--radius-md);
}

.lyrics-word {
  display: inline-block;
  padding: 2px 4px;
  margin: 0 2px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.lyrics-word:hover {
  background: var(--primary-purple);
  color: var(--white);
}

.lyrics-word.saved {
  background: rgba(124, 58, 237, 0.3);
  border-bottom: 2px solid var(--primary-purple);
}

/* ===== Word Popup ===== */
.word-popup {
  position: fixed;
  background: var(--gray-800);
  border: 1px solid var(--gray-600);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  box-shadow: var(--shadow-xl);
  z-index: 1000;
  min-width: 200px;
  animation: popupIn 0.2s ease;
}

@keyframes popupIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.word-popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-sm);
}

.word-popup-english {
  font-size: 1.25rem;
  font-weight: 600;
}

.word-popup-hebrew {
  font-size: 1.5rem;
  color: var(--primary-purple);
  direction: rtl;
  margin-bottom: var(--space-md);
}

.word-popup-close {
  background: none;
  border: none;
  color: var(--gray-400);
  cursor: pointer;
  font-size: 1.5rem;
}

/* ===== Player Bar ===== */
.player-bar {
  position: fixed;
  bottom: 60px;
  left: 0;
  right: 0;
  background: var(--gray-800);
  padding: var(--space-md);
  border-top: 1px solid var(--gray-700);
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.player-info {
  flex: 1;
  min-width: 0;
}

.player-title {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-artist {
  font-size: 0.875rem;
  color: var(--gray-400);
}

.player-controls {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.player-btn {
  background: none;
  border: none;
  color: var(--white);
  cursor: pointer;
  padding: var(--space-sm);
  border-radius: var(--radius-full);
  transition: background var(--transition-fast);
}

.player-btn:hover {
  background: var(--gray-700);
}

.player-btn-play {
  width: 48px;
  height: 48px;
  background: var(--primary-gradient);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.player-btn-play:hover {
  transform: scale(1.05);
}

.player-progress {
  flex: 2;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.progress-bar {
  flex: 1;
  height: 4px;
  background: var(--gray-600);
  border-radius: var(--radius-full);
  cursor: pointer;
  position: relative;
}

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

.progress-time {
  font-size: 0.75rem;
  color: var(--gray-400);
  min-width: 40px;
}

/* ===== Dictionary List ===== */
.dictionary-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.dictionary-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-md);
  background: var(--gray-800);
  border-radius: var(--radius-md);
}

.dictionary-item-word {
  font-weight: 600;
}

.dictionary-item-translation {
  color: var(--primary-purple);
  direction: rtl;
}

.dictionary-item-source {
  font-size: 0.75rem;
  color: var(--gray-400);
}

/* ===== Games ===== */
.game-card {
  background: var(--gray-800);
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  text-align: center;
}

.game-question {
  font-size: 1.5rem;
  margin-bottom: var(--space-xl);
}

.game-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-md);
}

.game-option {
  padding: var(--space-md);
  background: var(--gray-700);
  border: 2px solid var(--gray-600);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: 1rem;
  color: var(--white);
}

.game-option:hover {
  border-color: var(--primary-purple);
}

.game-option.correct {
  border-color: var(--success);
  background: rgba(16, 185, 129, 0.2);
}

.game-option.incorrect {
  border-color: var(--error);
  background: rgba(239, 68, 68, 0.2);
}

.game-score {
  font-size: 1.25rem;
  color: var(--primary-purple);
  margin-bottom: var(--space-md);
}

/* ===== Modals ===== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-normal);
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--gray-800);
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  max-width: 500px;
  width: 90%;
  transform: translateY(20px);
  transition: transform var(--transition-normal);
}

.modal-overlay.active .modal {
  transform: translateY(0);
}

/* ===== Animations ===== */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

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

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.animate-fadeIn { animation: fadeIn var(--transition-normal); }
.animate-slideUp { animation: slideUp var(--transition-normal); }
.animate-pulse { animation: pulse 2s infinite; }

/* ===== Loading States ===== */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-xl);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--gray-700);
  border-top-color: var(--primary-purple);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* ===== Utility Classes ===== */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.text-primary { color: var(--primary-purple); }
.text-secondary { color: var(--gray-400); }
.text-success { color: var(--success); }
.text-error { color: var(--error); }

.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mt-xl { margin-top: var(--space-xl); }

.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.mb-xl { margin-bottom: var(--space-xl); }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }

.hidden { display: none; }
.visible { display: block; }

/* ===== Responsive ===== */
@media (max-width: 768px) {
  h1 { font-size: 2rem; }
  h2 { font-size: 1.5rem; }

  .songs-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .player-bar {
    flex-wrap: wrap;
  }

  .player-progress {
    order: 3;
    flex-basis: 100%;
    margin-top: var(--space-sm);
  }

  .game-options {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .songs-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-sm);
  }

  .container {
    padding: 0 var(--space-sm);
  }
}
