/* Vocabulary Component Styles */
.vocabulary-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1rem;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: #f8f9fa;
  min-height: 100vh;
}

.vocabulary-controls {
  background: white;
  padding: 1.5rem;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 80, 239, 0.1);
  margin-bottom: 1.5rem;
  border: 1px solid #e9ecef;
}

/* Search and Filter Layout */
.controls-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 0.75rem;
}

#search-field, #search-input, #category-filter, #part-of-speech-filter {
  padding: 0.6rem 0.8rem;
  border: 2px solid #e9ecef;
  border-radius: 8px;
  font-size: 0.9rem;
  transition: all 0.3s ease;
  background: white;
  color: #333;
}

#search-field, #category-filter, #part-of-speech-filter {
  min-width: 180px;
}

#search-input {
  flex: 1;
  min-width: 250px;
}

#search-field:focus, #search-input:focus, 
#category-filter:focus, #part-of-speech-filter:focus {
  outline: none;
  border-color: #0050ef;
  box-shadow: 0 0 0 3px rgba(0, 80, 239, 0.1);
}

/* Filter Button */
.filter-btn {
  padding: 0.6rem 1.2rem;
  background: #0050ef;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.filter-btn:hover {
  background: #0040c7;
  transform: translateY(-1px);
}

/* Extra Filters */
.extra-filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.75rem;
  padding: 1rem;
  background: #f8f9fa;
  border-radius: 8px;
  margin-top: 0.75rem;
  border: 1px solid #e9ecef;
  transition: all 0.3s ease;
}

.extra-filters.hidden {
  display: none;
}

/* Word List - GRID LAYOUT WITH RESPONSIVE COLUMNS */
.word-list {
  display: grid;
  grid-template-columns: repeat(4, 1fr); /* 4 columns on desktop */
  gap: 1rem;
}

.word-item {
  background: white;
  border-radius: 10px;
  padding: 1rem;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
  transition: all 0.3s ease;
  cursor: pointer;
  border: 1px solid #e9ecef;
  break-inside: avoid; /* Prevent content breaking */
  word-wrap: break-word; /* Fix text overflow */
  overflow-wrap: break-word; /* Fix text overflow */
}

.word-item:hover:not(.expanded) {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 80, 239, 0.15);
  border-color: #0050ef;
}

/* EXPANDED STATE - FIXED */
.word-item.expanded {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 90%;
  max-width: 900px;
  max-height: 85vh;
  overflow-y: auto;
  z-index: 1000;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
  border-color: #0050ef;
  animation: expandModal 0.3s ease;
}

@keyframes expandModal {
  from {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

/* Overlay for expanded items */
.word-item.expanded::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #f8f9fa; /* Darker overlay for better contrast */
  z-index: -1;
  backdrop-filter: blur(2px);
}

/* Close hint for expanded items - FIXED */
.word-item.expanded::after {
  content: 'Click anywhere to close';
  position: fixed; /* Changed from absolute to fixed */
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #0050ef;
  color: white;
  padding: 0.6rem 1.2rem;
  border-radius: 25px;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  animation: fadeInOut 4s ease-in-out;
  z-index: 1001;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

@keyframes fadeInOut {
  0%, 100% { opacity: 0; transform: translateX(-50%) translateY(-10px); }
  20%, 80% { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Word Header - FIXED TEXT OVERFLOW */
.word-header {
  margin-bottom: 0;
}

.word-title {
  display: flex;
  align-items: flex-start; /* Changed to flex-start for better text handling */
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}

.word-title h2 {
  margin: 0;
  color: #0050ef;
  font-size: 1.3rem;
  font-weight: 700;
  line-height: 1.3;
  word-break: break-word; /* Fix long word overflow */
  overflow-wrap: break-word; /* Fix long word overflow */
}

.word-title p {
  margin: 0;
  color: #666;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.3;
  word-break: break-word; /* Fix long word overflow */
  overflow-wrap: break-word; /* Fix long word overflow */
}

/* Speaker Icon */
.speaker-icon {
  cursor: pointer;
  transition: all 0.3s ease;
  border-radius: 50%;
  padding: 2px;
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  margin-top: 2px; /* Align better with text */
}

.speaker-icon:hover {
  background: rgba(0, 80, 239, 0.1);
  transform: scale(1.05);
}

.speaker-icon:active {
  transform: scale(0.95);
}

/* Word Tags */
.word-tags {
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}

.word-tag {
  background: #0050ef;
  color: white;
  padding: 0.3rem 0.8rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.2px;
  white-space: nowrap;
}

/* Word Details - Regular state */
.word-details {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid #e9ecef;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: all 0.4s ease;
}

.word-details.expanded {
  max-height: none;
  opacity: 1;
}

/* Expanded content layout */
.word-item.expanded .word-header {
  margin-bottom: 1.5rem;
}

.word-item.expanded .word-details {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1.5rem;
  align-items: start;
  margin-top: 0;
  padding-top: 0;
  border-top: none;
  max-height: none;
  opacity: 1;
}

.word-item.expanded .word-image-container {
  grid-column: 1;
}

.word-item.expanded .word-image {
  max-width: 280px;
  margin-bottom: 0;
}

.word-item.expanded .word-content {
  grid-column: 2;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.word-item.expanded .word-content p {
  margin: 0;
  padding: 0.4rem 0;
  border-bottom: 1px solid #f0f0f0;
  word-break: break-word;
  overflow-wrap: break-word;
}

.word-item.expanded .word-content p:last-child {
  border-bottom: none;
}

/* Word Image */
.word-image {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  margin-bottom: 0.75rem;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

/* Video Styling */
.word-details video {
  border-radius: 6px;
  margin-top: 0.5rem;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  max-width: 100%;
}

/* Alternative: Return to Top Button above bottom nav */
.return-to-top {
  position: fixed;
  bottom: 5rem; /* Positioned above the bottom nav */
  right: 1rem;
  background: #0050ef;
  color: white;
  border: none;
  border-radius: 50%;
  width: 45px;
  height: 45px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 80, 239, 0.3);
  transition: all 0.3s ease;
  z-index: 1001; /* Higher than bottom nav */
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

.return-to-top:hover {
  background: #0040c7;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 80, 239, 0.4);
}

.return-to-top.visible {
  display: flex;
}

/* Desktop version (no bottom nav) */
@media (min-width: 1025px) {
  .return-to-top {
    bottom: 2rem;
    right: 2rem;
    width: 50px;
    height: 50px;
    font-size: 1.2rem;
  }
}

/* Responsive Design */
@media (max-width: 1200px) {
  .word-list {
    grid-template-columns: repeat(3, 1fr); /* 3 columns on smaller desktop */
  }
}

@media (max-width: 900px) {
  .word-list {
    grid-template-columns: repeat(2, 1fr); /* 2 columns on tablet */
  }
  
  .vocabulary-container {
    max-width: 100%;
    padding: 0.75rem;
  }
}

@media (max-width: 768px) {
  .vocabulary-controls {
    padding: 1.25rem;
  }
  
  .controls-row {
    flex-direction: column;
    align-items: stretch;
    gap: 0.6rem;
  }
  
  #search-field, #search-input, #category-filter, #part-of-speech-filter {
    min-width: auto;
    width: 100%;
  }
  
  .word-item.expanded {
    width: 95%;
    max-width: 95%;
    padding: 1.25rem;
  }
  
  .word-item.expanded .word-details {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  
  .word-item.expanded .word-image-container {
    grid-column: 1;
    text-align: center;
  }
  
  .word-item.expanded .word-content {
    grid-column: 1;
  }
  
  .word-title {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.3rem;
  }
  
  .extra-filters {
    grid-template-columns: 1fr;
    gap: 0.6rem;
    padding: 0.8rem;
  }
  
  
}

@media (max-width: 480px) {
  .word-list {
    grid-template-columns: 1fr; /* 1 column on mobile */
    gap: 0.75rem;
  }
  
  .vocabulary-container {
    padding: 0.5rem;
  }
  
  .vocabulary-controls {
    padding: 1rem;
  }
  
  .word-item {
    padding: 0.8rem;
  }
  
  .word-title h2 {
    font-size: 1.2rem;
  }
  
  .word-item.expanded {
    width: 98%;
    max-width: 98%;
    padding: 1rem;
  }
  
  .word-item.expanded::after {
    font-size: 0.75rem;
    padding: 0.5rem 1rem;
    top: 15px;
  }
}

/* Loading and Error States */
.word-list p {
  text-align: center;
  color: #666;
  font-size: 1rem;
  padding: 1.5rem;
  background: white;
  border-radius: 8px;
  margin: 0.75rem 0;
  border: 1px solid #e9ecef;
  grid-column: 1 / -1;
}

/* Selection colors */
::selection {
  background: rgba(215, 222, 236, 0.1);
}

::-moz-selection {
  background: rgba(0, 80, 239, 0.1);
}

/* Update the existing content padding for mobile */
@media (max-width: 1024px) {
  .content {
    margin-left: 0;
    padding-bottom: 90px; /* Increased from 80px to account for return button */
  }
}

/* Ad Container Styles */
.ad-container {
  margin: 1.5rem 0;
  text-align: center;
  width: 100%;
}

.top-banner-ad {
  margin: 1rem 0 2rem 0;
}

.in-grid-ad {
  grid-column: 1 / -1; /* Span all columns */
  margin: 1rem 0;
  background: #f8f9fa;
  padding: 1rem;
  border-radius: 8px;
  border: 1px solid #e9ecef;
}

.bottom-sticky-ad {
  position: sticky;
  bottom: 0;
  background: white;
  padding: 1rem;
  border-top: 1px solid #e9ecef;
  z-index: 99;
}

.expanded-ad {
  margin: 1.5rem 0;
  padding: 1rem;
  background: #f8f9fa;
  border-radius: 8px;
  border: 1px solid #e9ecef;
}

/* Mobile Responsive Ads */
@media (max-width: 768px) {
  .ad-container {
    margin: 1rem 0;
  }
  
  .in-grid-ad {
    margin: 0.75rem 0;
    padding: 0.75rem;
  }
  
  .bottom-sticky-ad {
    position: relative;
    bottom: auto;
    margin-top: 2rem;
  }
  
  .expanded-ad {
    margin: 1rem 0;
    padding: 0.75rem;
  }
}

/* Ensure ads don't break layout */
.vocabulary-container .ad-container {
  box-sizing: border-box;
}

