/* Interactive Vocabulary Buttons & Popup Styles */

:root {
  --primary-color: #667eea;
  --primary-dark: #5a6fd8;
  --secondary-color: #764ba2;
  --success-color: #28a745;
  --danger-color: #dc3545;
  --warning-color: #ffc107;
  --info-color: #17a2b8;
  --light-color: #f8f9fa;
  --dark-color: #343a40;
  --border-radius: 8px;
  --box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  --transition: all 0.3s ease;
  
  /* Light theme colors */
  --bg-color: #f5f7fa;
  --text-color: #343a40;
  --card-bg: #ffffff;
  --border-color: #e9ecef;
  --hover-bg: #f8f9fa;
  --input-bg: #ffffff;
  --popup-bg: #ffffff;
  --shadow: rgba(0,0,0,0.1);
}

/* Dark theme colors */
body.dark-theme {
  --bg-color: #1a1a1a;
  --text-color: #e9ecef;
  --card-bg: #2d3748;
  --border-color: #4a5568;
  --hover-bg: #4a5568;
  --input-bg: #2d3748;
  --popup-bg: #2d3748;
  --shadow: rgba(0,0,0,0.5);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.6;
  color: var(--text-color);
  background-color: var(--bg-color);
  transition: var(--transition);
}

/* Container */
.vocab-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.03) 0%, rgba(118, 75, 162, 0.03) 100%);
  border-radius: 16px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.1);
}

/* Header */
.vocab-header {
  text-align: center;
  margin-bottom: 40px;
  padding: 50px 30px;
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
  color: white;
  border-radius: 20px;
  box-shadow: 0 8px 32px rgba(102, 126, 234, 0.3);
  position: relative;
  overflow: hidden;
}

.vocab-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(45deg, transparent 30%, rgba(255,255,255,0.1) 50%, transparent 70%);
  opacity: 0;
  transition: opacity 0.6s ease;
}

.vocab-header:hover::before {
  opacity: 1;
  animation: shimmer 2s ease-in-out infinite;
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  50% { transform: translateX(100%); }
  100% { transform: translateX(100%); }
}

.vocab-header h1 {
  font-size: 2.8rem;
  margin-bottom: 20px;
  font-weight: 800;
  text-shadow: 0 2px 4px rgba(0,0,0,0.2);
  letter-spacing: -0.5px;
}

.category-icon {
  font-size: 3rem;
  margin-right: 15px;
  display: inline-block;
  animation: bounce 2s ease-in-out infinite;
}

@keyframes bounce {
  0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-10px); }
  60% { transform: translateY(-5px); }
}

.category-description {
  font-size: 1.2rem;
  opacity: 0.95;
  max-width: 600px;
  margin: 0 auto 20px;
  line-height: 1.6;
}

.vocab-stats {
  display: flex;
  justify-content: center;
  gap: 30px;
  margin-top: 25px;
  flex-wrap: wrap;
}

.vocab-stats span {
  background: rgba(255,255,255,0.2);
  padding: 12px 24px;
  border-radius: 25px;
  font-weight: 600;
  font-size: 1rem;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.3);
}

/* Category Info */
.category-info {
  background: white;
  padding: 30px;
  border-radius: var(--border-radius);
  box-shadow: var(--box-shadow);
  margin-bottom: 30px;
  text-align: center;
}

.category-info h2 {
  color: var(--primary-color);
  margin-bottom: 15px;
  font-size: 2rem;
}

.category-info .description {
  color: #6c757d;
  font-size: 1.1rem;
  margin-bottom: 20px;
}

.word-count {
  display: inline-block;
  background: var(--primary-color);
  color: white;
  padding: 8px 16px;
  border-radius: 20px;
  font-weight: 600;
  font-size: 0.9rem;
}

/* Search & Filter */
.vocab-controls {
  background: var(--card-bg);
  padding: 30px;
  border-radius: 16px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
  margin-bottom: 30px;
  border: 1px solid var(--border-color);
  backdrop-filter: blur(10px);
}

/* Search Container */
.search-container {
  position: relative;
  max-width: 600px;
  margin: 0 auto 30px;
}

.search-input {
  width: 100%;
  padding: 18px 70px 18px 24px;
  font-size: 16px;
  border: 2px solid var(--border-color);
  border-radius: 30px;
  outline: none;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  background: var(--input-bg);
  color: var(--text-color);
  font-weight: 500;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.search-input::placeholder {
  color: rgba(107, 114, 128, 0.7);
  font-weight: 400;
}

.search-input:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.15), 0 4px 16px rgba(0,0,0,0.1);
  transform: translateY(-2px);
}

.vocab-controls .search-icon {
  position: absolute;
  right: 15px;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--primary-color);
  background: rgba(102, 126, 234, 0.1);
  border-radius: 50%;
  pointer-events: none;
  transition: all 0.3s ease;
  border: 1px solid rgba(102, 126, 234, 0.2);
}

.search-input:focus + .vocab-controls .search-icon,
.vocab-controls .search-input:focus + .search-icon {
  background: var(--primary-color);
  color: white;
  transform: translateY(-50%) scale(1.05);
  border-color: var(--primary-color);
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.search-results {
  text-align: center;
  margin-top: 15px;
  color: var(--text-color);
  font-size: 0.95rem;
  font-weight: 500;
}

/* Alphabet Filter */
.alphabet-container h3 {
  text-align: center;
  margin-bottom: 20px;
  color: var(--text-color);
  font-size: 1.1rem;
  font-weight: 600;
}

.alphabet-filter {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
}

.alphabet-btn {
  width: 45px;
  height: 45px;
  border: 2px solid var(--border-color);
  background: var(--card-bg);
  color: var(--text-color);
  border-radius: 12px;
  cursor: pointer;
  font-weight: 700;
  font-size: 1rem;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.alphabet-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(102, 126, 234, 0.2), transparent);
  transition: left 0.5s;
}

.alphabet-btn:hover::before {
  left: 100%;
}

.alphabet-btn:hover {
  border-color: var(--primary-color);
  background: var(--primary-color);
  color: white;
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.3);
}

.alphabet-btn.active {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.clear-filter {
  background: linear-gradient(135deg, #6c757d 0%, #5a6268 100%);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 25px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  transition: all 0.3s ease;
  margin-top: 15px;
  box-shadow: 0 4px 15px rgba(108, 117, 125, 0.3);
}

.clear-filter:hover {
  background: linear-gradient(135deg, #5a6268 0%, #495057 100%);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(108, 117, 125, 0.4);
}

/* Words Grid */
.words-section {
  background: var(--card-bg);
  border-radius: 20px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
  margin-bottom: 40px;
  border: 1px solid var(--border-color);
  overflow: hidden;
}

.words-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 20px;
  padding: 40px 30px;
}

/* Word Buttons */
.word-btn {
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
  color: white;
  border: none;
  border-radius: 16px;
  padding: 24px 20px;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  text-align: center;
  word-wrap: break-word;
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.25);
  position: relative;
  overflow: hidden;
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 0.5px;
  text-transform: capitalize;
}

.word-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
  transition: left 0.6s ease;
}

.word-btn:hover::before {
  left: 100%;
}

.word-btn::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.1) 0%, transparent 50%);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.word-btn:hover::after {
  opacity: 1;
}

.word-btn:hover {
  transform: translateY(-6px) scale(1.03);
  box-shadow: 0 12px 40px rgba(102, 126, 234, 0.4);
  border: 2px solid rgba(255,255,255,0.2);
}

.word-btn:active {
  transform: translateY(-2px) scale(0.98);
  transition: transform 0.1s ease;
}

/* Loading Animation */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-color);
}

.loading-spinner {
  width: 50px;
  height: 50px;
  border: 4px solid var(--border-color);
  border-top: 4px solid var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 20px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.loading p {
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--text-color);
  opacity: 0.8;
}

/* Category Navigation */
.category-nav {
  background: var(--card-bg);
  border-radius: 20px;
  padding: 40px 30px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
  border: 1px solid var(--border-color);
  margin-bottom: 30px;
}

.category-nav h3 {
  text-align: center;
  margin-bottom: 30px;
  color: var(--text-color);
  font-size: 1.4rem;
  font-weight: 700;
  position: relative;
}

.category-nav h3::after {
  content: '';
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 3px;
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
  border-radius: 2px;
}

.category-links {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}

.category-link {
  display: flex;
  align-items: center;
  padding: 20px 24px;
  background: var(--card-bg);
  color: var(--text-color);
  text-decoration: none;
  border-radius: 16px;
  border: 2px solid var(--border-color);
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  font-weight: 600;
  font-size: 1rem;
  position: relative;
  overflow: hidden;
}

.category-link::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(102, 126, 234, 0.1), transparent);
  transition: left 0.6s ease;
}

.category-link:hover::before {
  left: 100%;
}

.category-link .category-icon {
  font-size: 1.8rem;
  margin-right: 15px;
  transition: transform 0.3s ease;
}

.category-link:hover {
  transform: translateY(-4px) scale(1.02);
  border-color: var(--primary-color);
  box-shadow: 0 8px 30px rgba(102, 126, 234, 0.2);
}

.category-link:hover .category-icon {
  transform: scale(1.2) rotate(10deg);
}

.category-link.active {
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
  color: white;
  border-color: var(--primary-color);
  transform: translateY(-4px);
  box-shadow: 0 8px 30px rgba(102, 126, 234, 0.4);
}

.category-link.active .category-icon {
  transform: scale(1.1);
}

/* Popup Modal */
.word-popup {
  position: absolute;
  background: var(--popup-bg);
  border: 2px solid var(--primary-color);
  border-radius: 12px;
  padding: 16px;
  max-width: 350px;
  min-width: 280px;
  width: auto;
  box-shadow: 0 8px 25px var(--shadow);
  z-index: 1000;
  display: none;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.3s ease;
  pointer-events: none;
  resize: both;
  overflow: auto;
  min-height: 200px;
  max-height: 80vh;
}

.word-popup.active {
  display: block;
  opacity: 1;
  transform: translateY(-10px);
  pointer-events: all;
}

/* Arrow pointing down to the clicked word */
.word-popup::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 8px solid transparent;
  border-top-color: var(--primary-color);
  pointer-events: none;
}

/* Responsive breakpoints */
@media (max-width: 768px) {
  .word-popup {
    max-width: 90vw;
    min-width: 260px;
    width: 85vw;
    resize: none; /* Disable resize on mobile */
    max-height: 70vh;
    padding: 14px;
  }
  
  .word-popup::after {
    left: 20px; /* Position arrow towards left on mobile */
    transform: translateX(0);
  }
}

@media (max-width: 480px) {
  .word-popup {
    max-width: 95vw;
    min-width: 240px;
    width: 90vw;
    padding: 12px;
    max-height: 60vh;
    font-size: 0.9rem;
  }
  
  .word-popup::after {
    left: 15px;
  }
}

@media (max-width: 320px) {
  .word-popup {
    max-width: 98vw;
    min-width: 220px;
    width: 95vw;
    padding: 10px;
    max-height: 55vh;
    font-size: 0.85rem;
  }
  
  .word-popup::after {
    left: 12px;
  }
}

.popup-content {
  background: transparent;
  border-radius: 0;
  max-width: none;
  width: 100%;
  max-height: none;
  overflow-y: visible;
  position: static;
  animation: none;
  box-shadow: none;
}

.popup-header {
  background: transparent;
  color: var(--text-color);
  padding: 0 0 12px 0;
  border-radius: 0;
  position: relative;
  border-bottom: 2px solid var(--primary-color);
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 8px;
}

.popup-word {
  font-size: 1.4rem;
  font-weight: 700;
  margin: 0;
  text-align: left;
  color: var(--primary-color);
  flex: 1;
  min-width: 0;
  word-break: break-word;
}

.popup-pronunciation {
  text-align: left;
  opacity: 0.8;
  font-size: 0.9rem;
  margin-top: 4px;
  font-style: italic;
  color: var(--text-color);
  word-break: break-word;
}

.popup-close {
  position: relative;
  top: 0;
  right: 0;
  background: #e53e3e;
  border: none;
  color: white;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-size: 14px;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Responsive header adjustments */
@media (max-width: 480px) {
  .popup-word {
    font-size: 1.2rem;
  }
  
  .popup-close {
    width: 20px;
    height: 20px;
    font-size: 12px;
  }
  
  .popup-pronunciation {
    font-size: 0.8rem;
  }
}

@media (max-width: 320px) {
  .popup-word {
    font-size: 1.1rem;
  }
  
  .popup-close {
    width: 18px;
    height: 18px;
    font-size: 11px;
  }
  
  .popup-pronunciation {
    font-size: 0.75rem;
  }
}

.popup-close:hover {
  background: #dc3545;
  transform: scale(1.1);
}

.popup-body {
  padding: 0;
  overflow-y: auto;
  max-height: calc(100% - 120px); /* Reserve space for header and navigation */
}

.meaning-section {
  margin-bottom: 12px;
}

.meaning-label {
  font-weight: 600;
  color: var(--primary-color);
  font-size: 0.9rem;
  margin-bottom: 4px;
  display: block;
}

.meaning-text {
  font-size: 0.95rem;
  color: var(--text-color);
  line-height: 1.4;
  background: var(--card-bg);
  padding: 8px 12px;
  border-radius: 6px;
  border-left: 3px solid var(--primary-color);
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.example-section {
  margin-bottom: 12px;
}

.example-label {
  font-weight: 600;
  color: var(--success-color);
  font-size: 0.9rem;
  margin-bottom: 4px;
  display: block;
}

.example-text {
  font-size: 0.95rem;
  color: var(--text-color);
  line-height: 1.4;
  background: var(--card-bg);
  padding: 8px 12px;
  border-radius: 6px;
  border-left: 3px solid var(--success-color);
  font-style: italic;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.example-word {
  font-weight: 600;
  color: var(--success-color);
}

/* Popup Navigation */
.popup-navigation {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
  margin-top: 12px;
  gap: 8px;
  flex-wrap: wrap;
}

.nav-btn {
  background: var(--primary-color);
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
  font-size: 0.85rem;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  min-width: 0;
}

.nav-btn:hover:not(:disabled) {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

.nav-btn:disabled {
  background: #6c757d;
  cursor: not-allowed;
  opacity: 0.5;
}

.word-counter {
  font-size: 0.8rem;
  color: var(--text-color);
  font-weight: 500;
  text-align: center;
  white-space: nowrap;
  min-width: 0;
  flex-shrink: 0;
}

/* Responsive adjustments for popup body */
@media (max-width: 480px) {
  .popup-body {
    max-height: calc(100% - 110px);
  }
  
  .meaning-text,
  .example-text {
    font-size: 0.9rem;
    padding: 6px 10px;
  }
  
  .meaning-label,
  .example-label {
    font-size: 0.85rem;
  }
  
  .popup-navigation {
    padding-top: 10px;
    margin-top: 10px;
    gap: 6px;
  }
  
  .nav-btn {
    padding: 5px 8px;
    font-size: 0.8rem;
  }
  
  .word-counter {
    font-size: 0.75rem;
    order: 3;
    flex-basis: 100%;
    text-align: center;
    margin-top: 6px;
  }
}

@media (max-width: 320px) {
  .popup-body {
    max-height: calc(100% - 100px);
  }
  
  .meaning-text,
  .example-text {
    font-size: 0.85rem;
    padding: 5px 8px;
  }
  
  .meaning-label,
  .example-label {
    font-size: 0.8rem;
  }
  
  .nav-btn {
    padding: 4px 6px;
    font-size: 0.75rem;
    gap: 2px;
  }
  
  .word-counter {
    font-size: 0.7rem;
  }
}

.word-counter {
  color: #6c757d;
  font-size: 0.9rem;
  font-weight: 600;
}

/* Audio Button */
.audio-btn {
  background: var(--info-color);
  color: white;
  border: none;
  padding: 8px 12px;
  border-radius: var(--border-radius);
  cursor: pointer;
  font-size: 0.9rem;
  margin-left: 10px;
  transition: var(--transition);
}

.audio-btn:hover {
  background: #138496;
  transform: scale(1.05);
}

/* Loading & Empty States */
.loading {
  text-align: center;
  padding: 50px;
  color: #6c757d;
}

.loading::after {
  content: '';
  display: inline-block;
  width: 40px;
  height: 40px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-left: 10px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.no-results {
  text-align: center;
  padding: 50px;
  color: #6c757d;
  grid-column: 1 / -1;
}

.no-results h3 {
  font-size: 1.5rem;
  margin-bottom: 10px;
  color: var(--primary-color);
}

/* Enhanced Responsive Design */
@media (max-width: 768px) {
  .vocab-container {
    padding: 15px;
    margin: 10px;
  }

  .vocab-header {
    padding: 40px 20px;
    margin-bottom: 30px;
  }

  .vocab-header h1 {
    font-size: 2.2rem;
  }

  .category-icon {
    font-size: 2.5rem;
    margin-right: 10px;
  }

  .vocab-stats {
    flex-direction: column;
    gap: 15px;
  }

  .vocab-controls {
    padding: 25px 20px;
  }

  .search-container {
    margin-bottom: 25px;
    max-width: 100%;
  }

  .search-input {
    padding: 16px 65px 16px 20px;
    font-size: 15px;
  }

  .vocab-controls .search-icon {
    right: 12px;
    width: 40px;
    height: 40px;
    font-size: 16px;
  }

  .alphabet-filter {
    gap: 8px;
  }

  .alphabet-btn {
    width: 40px;
    height: 40px;
    font-size: 0.9rem;
  }

  .words-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 15px;
    padding: 30px 20px;
  }

  .word-btn {
    padding: 20px 16px;
    font-size: 1rem;
    min-height: 70px;
  }

  .category-nav {
    padding: 30px 20px;
  }

  .category-links {
    grid-template-columns: 1fr;
    gap: 15px;
  }

  .category-link {
    padding: 18px 20px;
    font-size: 0.95rem;
  }

  .category-link .category-icon {
    font-size: 1.6rem;
    margin-right: 12px;
  }

  .popup-content {
    width: 95%;
    margin: 20px;
  }

  .popup-word {
    font-size: 2rem;
  }

  .popup-body {
    padding: 20px;
  }

  .alphabet-filter {
    gap: 6px;
  }

  .alphabet-btn {
    width: 35px;
    height: 35px;
    font-size: 0.8rem;
  }

  .popup-navigation {
    flex-direction: column;
    gap: 15px;
  }

  .nav-btn {
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .vocab-header h1 {
    font-size: 1.8rem;
  }

  .category-icon {
    font-size: 2rem;
    margin-right: 8px;
  }

  .vocab-header {
    padding: 30px 15px;
  }

  .vocab-controls {
    padding: 20px 15px;
  }

  .search-container {
    max-width: 100%;
    margin-bottom: 20px;
  }

  .search-input {
    padding: 14px 60px 14px 18px;
    font-size: 14px;
    border-radius: 25px;
  }

  .vocab-controls .search-icon {
    right: 10px;
    width: 36px;
    height: 36px;
    font-size: 14px;
  }

  .alphabet-btn {
    width: 35px;
    height: 35px;
    font-size: 0.8rem;
  }

  .words-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    padding: 25px 15px;
  }

  .word-btn {
    padding: 16px 12px;
    font-size: 0.9rem;
    min-height: 60px;
  }

  .category-nav {
    padding: 25px 15px;
  }

  .category-nav h3 {
    font-size: 1.2rem;
  }

  .category-link {
    padding: 16px 18px;
    font-size: 0.9rem;
  }

  .category-link .category-icon {
    font-size: 1.4rem;
    margin-right: 10px;
  }
}

/* Animation for word buttons */
.word-btn {
  animation: fadeInUp 0.5s ease forwards;
  opacity: 0;
  transform: translateY(20px);
}

@keyframes fadeInUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== DARK THEME SUPPORT ===== */

/* Dark Theme Specific Overrides */
body.dark-theme .vocab-container {
  background-color: var(--bg-color);
}

body.dark-theme .vocab-stats span {
  background: var(--card-bg);
  color: var(--text-color);
  border: 1px solid var(--border-color);
}

body.dark-theme .search-input {
  background: var(--input-bg);
  color: var(--text-color);
  border-color: var(--border-color);
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

body.dark-theme .search-input::placeholder {
  color: rgba(160, 174, 192, 0.7);
}

body.dark-theme .search-input:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 4px rgba(144, 202, 249, 0.15), 0 4px 16px rgba(0,0,0,0.3);
}

body.dark-theme .vocab-controls .search-icon {
  color: var(--primary-color);
  background: rgba(144, 202, 249, 0.1);
  border-color: rgba(144, 202, 249, 0.2);
}

body.dark-theme .search-input:focus + .vocab-controls .search-icon,
body.dark-theme .vocab-controls .search-input:focus + .search-icon {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

body.dark-theme .search-input::placeholder {
  color: #a0aec0;
}

body.dark-theme .alphabet-btn {
  background: var(--card-bg);
  color: var(--text-color);
  border-color: var(--border-color);
}

body.dark-theme .alphabet-btn:hover {
  background: var(--hover-bg);
  transform: translateY(-2px);
}

body.dark-theme .alphabet-btn.active {
  background: var(--primary-color);
  color: white;
}

body.dark-theme .clear-filter {
  background: #e53e3e;
  color: white;
}

body.dark-theme .word-btn {
  background: var(--card-bg);
  color: var(--text-color);
  border: 2px solid var(--border-color);
  box-shadow: 0 2px 8px var(--shadow);
}

body.dark-theme .word-btn:hover {
  background: var(--hover-bg);
  border-color: var(--primary-color);
  transform: translateY(-3px);
  box-shadow: 0 4px 15px var(--shadow);
}

body.dark-theme .word-btn:active,
body.dark-theme .word-btn.active {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

body.dark-theme .category-link {
  background: var(--card-bg);
  color: var(--text-color);
  border: 1px solid var(--border-color);
}

body.dark-theme .category-link:hover {
  background: var(--hover-bg);
  border-color: var(--primary-color);
  transform: translateY(-2px);
}

body.dark-theme .category-link.active {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

body.dark-theme .word-popup {
  background: var(--popup-bg);
  border-color: var(--primary-color);
  box-shadow: 0 8px 25px var(--shadow);
}

body.dark-theme .word-popup::after {
  border-top-color: var(--primary-color);
}

body.dark-theme .popup-word {
  color: var(--primary-color);
}

body.dark-theme .popup-pronunciation {
  color: var(--text-color);
}

body.dark-theme .popup-close {
  background: #e53e3e;
  color: white;
}

body.dark-theme .popup-close:hover {
  background: #dc3545;
}

body.dark-theme .meaning-label,
body.dark-theme .example-label {
  color: var(--primary-color);
}

body.dark-theme .meaning-text,
body.dark-theme .example-text {
  background: var(--card-bg);
  color: var(--text-color);
}

body.dark-theme .popup-navigation {
  border-top: 1px solid var(--border-color);
}

body.dark-theme .nav-btn {
  background: var(--primary-color);
  color: white;
}

body.dark-theme .nav-btn:hover:not(:disabled) {
  background: var(--primary-dark);
}

body.dark-theme .nav-btn:disabled {
  background: var(--border-color);
  color: #a0aec0;
}

body.dark-theme .word-counter {
  color: var(--text-color);
}

body.dark-theme .loading {
  color: var(--text-color);
}

body.dark-theme .no-results h3 {
  color: var(--text-color);
}

body.dark-theme .no-results p {
  color: #a0aec0;
}

/* Enhanced animations for theme transitions */
* {
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

/* Staggered animation for word buttons */
.word-btn:nth-child(1) { animation-delay: 0.1s; }
.word-btn:nth-child(2) { animation-delay: 0.15s; }
.word-btn:nth-child(3) { animation-delay: 0.2s; }
.word-btn:nth-child(4) { animation-delay: 0.25s; }
.word-btn:nth-child(5) { animation-delay: 0.3s; }
.word-btn:nth-child(6) { animation-delay: 0.35s; }
.word-btn:nth-child(7) { animation-delay: 0.4s; }
.word-btn:nth-child(8) { animation-delay: 0.45s; }
.word-btn:nth-child(9) { animation-delay: 0.5s; }
.word-btn:nth-child(10) { animation-delay: 0.55s; }
.word-btn:nth-child(n+11) { animation-delay: 0.6s; }

/* Smooth transitions for filtering */
.words-grid.filtering .word-btn {
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.words-grid.filtering .word-btn.hidden {
  opacity: 0;
  transform: scale(0.8) translateY(20px);
  pointer-events: none;
}

/* Enhanced focus states for accessibility */
.word-btn:focus,
.alphabet-btn:focus,
.category-link:focus,
.search-input:focus {
  outline: 3px solid rgba(102, 126, 234, 0.4);
  outline-offset: 2px;
}

/* Pulse animation for active elements */
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(102, 126, 234, 0.4); }
  70% { box-shadow: 0 0 0 10px rgba(102, 126, 234, 0); }
  100% { box-shadow: 0 0 0 0 rgba(102, 126, 234, 0); }
}

.word-btn.pulse {
  animation: pulse 0.6s ease-out;
}

/* Smooth page transitions */
.vocab-container {
  animation: fadeIn 0.6s ease-out;
}

@keyframes fadeIn {
  from { 
    opacity: 0; 
    transform: translateY(30px); 
  }
  to { 
    opacity: 1; 
    transform: translateY(0); 
  }
}

/* Enhanced loading state */
.loading {
  animation: fadeIn 0.5s ease-out;
}

.loading-spinner {
  background: conic-gradient(from 0deg, transparent, var(--primary-color));
  border: none;
  border-radius: 50%;
}

/* Improved scrollbar styling */
.words-section::-webkit-scrollbar,
.popup-body::-webkit-scrollbar {
  width: 8px;
}

.words-section::-webkit-scrollbar-track,
.popup-body::-webkit-scrollbar-track {
  background: var(--border-color);
  border-radius: 4px;
}

.words-section::-webkit-scrollbar-thumb,
.popup-body::-webkit-scrollbar-thumb {
  background: var(--primary-color);
  border-radius: 4px;
}

.words-section::-webkit-scrollbar-thumb:hover,
.popup-body::-webkit-scrollbar-thumb:hover {
  background: var(--primary-dark);
}
