/* Global height setup */
html, body {
  height: 100%;
}

#all-content-section {
  flex: 1;
}

/* Footer styles */
.footer {
  flex-shrink: 0;
}

.footer .list-inline-item {
  margin-bottom: 10px;
}

/* FIXED: Consolidated button grid definitions and added clear responsive breakpoints */
.button-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr); /* Default for smallest screens */
  gap: 5px;
  justify-content: center;
  margin: 0 auto;
  max-width: 100%;
  width: 100%;
}

/* FIXED: Consolidated media queries for better organization */
/* Mobile and tablet styles */
@media (max-width: 991.98px) {
  /* Search visibility for mobile */
  .desktop-search {
    display: none !important;
  }
  
  .mobile-search {
    display: block !important;
    width: 100%;
    margin: 10px 0;
  }
  
  .navbar-nav {
    margin-top: 10px;
  }
  
  /* Button grid stays at 3 columns for small screens (defined in the main rule) */
}

/* Medium screens */
@media (min-width: 576px) and (max-width: 767.98px) {
  .button-grid {
    grid-template-columns: repeat(5, 1fr);
  }
}

/* Large screens */
@media (min-width: 768px) and (max-width: 991.98px) {
  .button-grid {
    grid-template-columns: repeat(6, 1fr);
  }
}

/* Extra large screens */
@media (min-width: 992px) and (max-width: 1199.98px) {
  .button-grid {
    grid-template-columns: repeat(7, 1fr);
  }
  
  /* Search visibility for desktop */
  .desktop-search {
    display: flex !important;
    width: 220px;
  }
  
  .mobile-search {
    display: none !important;
  }
}

/* XXL screens */
@media (min-width: 1200px) {
  .button-grid {
    grid-template-columns: repeat(9, 1fr);
    max-width: 1200px;
  }
  
  /* Search visibility remains the same as large desktop */
  .desktop-search {
    display: flex !important;
    width: 220px;
  }
  
  .mobile-search {
    display: none !important;
  }
}

/* Button item styling */
.button-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
  width: 100%;
  min-width: 0;
}

/* FIXED: Improved navbar styling organization */
.navbar {
  position: sticky;
  top: 0;
  z-index: 1000; /* FIXED: Added clear z-index for stacking context */
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.navbar-brand {
  margin-left: 12px !important;
}

.navbar-brand p {
  margin-bottom: 0;
  margin-top: 8px;
}

.navbar .nav-link {
  white-space: nowrap;
  padding-left: 0.75rem !important;
  padding-right: 0.75rem !important;
}

/* Login button styling */
.login-button {
  display: inline-block;
  padding: 5px 11px;
  color: white;
  text-decoration: none;
  border: 2px solid;
  border-radius: 5px;
  background-color: transparent;
  font-size: 14px;
  transition: all 0.3s ease;
}

/* FIXED: Organized search styling more logically */
.search-container {
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background-color: rgba(255, 255, 255, 0.1);
  transition: all 0.3s ease;
}

.search-container:hover, 
.search-container:focus-within {
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.2);
  background-color: rgba(255, 255, 255, 0.15);
}

.search-input {
  border: none;
  background-color: transparent;
  color: #fff;
  padding-left: 15px;
}

.search-input::placeholder {
  color: rgba(255, 255, 255, 0.6);
}

.search-input:focus {
  box-shadow: none;
  background-color: transparent;
  color: #fff;
}

.search-button {
  background-color: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.8);
  padding: 0 15px;
  cursor: pointer;
  transition: color 0.3s ease;
}

.search-button:hover {
  color: #fff;
}

/* FIXED: Organized instant button styles and reduced repetition */
.instant {
  position: relative;
  vertical-align: top;
  width: 94px;
  text-align: center;
  word-wrap: break-word;
  margin: 0 15px;
}

/* FIXED: Added url variables for easier maintenance */
:root {
  --small-button-sprite: url('/static/landingpage/images/transparent_button_small_sprite.webp');
  --small-button-shadow: url('/static/landingpage/images/transparent_button_small_shadow.png');
  --large-button-sprite: url('/static/landingpage/images/transparent_button_sprite.webp');
  --large-button-shadow: url('/static/landingpage/images/transparent_button_shadow.png');
}

/* Small button styles */
.small-button {
  width: 94px;
  height: 89px;
  position: absolute;
  background: var(--small-button-sprite) no-repeat;
  background-position: -5px -5px;
  border: 0;
  display: block;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
  z-index: 2; /* FIXED: Clear stacking order */
}

.small-button:focus {
  background: var(--small-button-sprite) no-repeat;
  background-position: -5px -5px;
}

.small-button:active {
  background: var(--small-button-sprite) no-repeat;
  background-position: -109px -5px;
  transform: scale(0.95) translateY(2px);
  transition: transform 0.1s ease-in-out;
}

.small-button-background {
  width: 86px;
  height: 84px;
  margin-top: 3px;
  margin-left: 3px;
  position: absolute;
  z-index: 1; /* FIXED: Clear stacking order */
}

.small-button-shadow {
  width: 94px;
  height: 89px;
  margin-bottom: 5px;
  background: var(--small-button-shadow) no-repeat;
  position: relative;
  z-index: 0; /* FIXED: Clear stacking order */
}

.small-button-shadow:active {
  opacity: 0.6;
  transition: opacity 0.1s ease-in-out;
}

/* Large button styles */
.large-button {
  width: 200px;
  height: 190px;
  position: absolute;
  background: var(--large-button-sprite) no-repeat;
  background-position: -5px -5px;
  border: 0;
  display: block;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
  z-index: 2; /* FIXED: Clear stacking order */
}

.large-button:focus {
  background: var(--large-button-sprite) no-repeat;
  background-position: -5px -5px;
}

.large-button:active {
  background: var(--large-button-sprite) no-repeat;
  background-position: -215px -5px;
  transform: scale(0.96) translateY(3px);
  transition: transform 0.1s ease-in-out;
}

.large-button-background {
  width: 188px;
  height: 174px;
  margin-top: 7px;
  margin-left: 6px;
  position: absolute;
  z-index: 1; /* FIXED: Clear stacking order */
}

.large-button-shadow {
  width: 200px;
  height: 190px;
  background: var(--large-button-shadow) no-repeat;
  position: relative;
  z-index: 0; /* FIXED: Clear stacking order */
}

.large-button-shadow:active {
  opacity: 0.6;
  transition: opacity 0.1s ease-in-out;
}

/* Shape utilities */
.circle {
  border-radius: 50%;
}

/* FIXED: Consolidated loader styles */
.loader, .loader-large, #loading {
  border-style: solid;
  border-color: transparent;
  border-top-color: #747474;
  border-radius: 50%;
  animation: spin 2s linear infinite;
  display: none;
  position: absolute;
}

.loader {
  top: -2px;
  left: -1px;
  border-width: 5px;
  width: 94px;
  height: 94px;
}

.loader-large {
  border-width: 8px;
  width: 190px;
  height: 190px;
  margin: -1px 0 0 4px;
}

#loading {
  border-width: 5px;
  width: 32px;
  height: 32px;
  margin: 0 auto 40px;
  animation-duration: 1s;
  display: block; /* FIXED: Ensure visibility differs from other loaders */
  position: relative; /* FIXED: Different positioning from other loaders */
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Large instant layout */
.large-instant {
  position: relative;
  vertical-align: top;
  width: 200px;
  text-align: center;
  word-wrap: break-word;
}

.large-instant .instant-link {
  margin-top: 195px;
}

/* Instant action buttons */
.instant-action-button-icon {
  width: 25px;
  height: 25px;
  padding-left: 0.5px;
}

.instant-action-button {
  padding: 0;
  background: none;
  border: 0;
}

.result-page-instant-sharebox {
  margin: 8px 0 0 0;
}

.instant-link {
  font-size: 14px;
  font-weight: 500;
  margin-top: 8px;
  margin-bottom: 8px;
}

/* FIXED: Organized blog styling */
.blog-card {
  transition: transform 0.3s;
}

.blog-card:hover {
  transform: translateY(-5px) scale(1.05); /* FIXED: Combined transformations */
}

.blog-image-container {
  height: 250px;
  overflow: hidden;
  background-color: #f8f9fa;
}

.blog-image-container img {
  width: 100%;
  height: 180px; /* FIXED: Conflicting with container height, using specific selector */
  object-fit: cover;
}

.blog-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Empty blogs styling */
.no-blogs-container {
  padding: 80px 0;
  text-align: center;
}

.no-blogs-icon {
  font-size: 5rem;
  color: #6c757d;
  margin-bottom: 20px;
}

/* FIXED: Organized instant page extra buttons */
#instant-page-extra-buttons-container {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 15px; 
  margin: 20px auto;
  max-width: 900px;
}

.instant-page-extra-button {
  flex: 0 0 calc(33.33% - 20px); 
  max-width: 280px;
  min-width: 250px;
  text-align: center;
  padding: 10px;
  color: white;
  border: none;
  font-size: 16px;
  background-color: #375a7f; /* FIXED: Consolidated repeated colors */
}

@media screen and (max-width: 768px) {
  .instant-page-extra-button {
    flex: 0 0 calc(50% - 20px); 
  }
}

@media screen and (max-width: 480px) {
  .instant-page-extra-button {
    flex: 0 0 100%; 
  }
}

/* Sound title styling */
.sound-title {
  display: block;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
  height: 20px;
  line-height: 20px;
}

/* Load more container */
.load-more-container {
  text-align: center;
  margin: 30px 0;
  width: 100%;
  display: flex;
  justify-content: center;
}

.load-more-btn {
  background-color: #6c757d;
  color: white;
  padding: 6px 20px;
  border-radius: 4px;
  border: none;
  font-size: 14px;
  font-weight: 500;
  transition: background-color 0.3s;
  display: inline-block;
}

.load-more-btn:hover {
  background-color: #5a6268;
}

.load-more-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

/* Button spinner */
.button-spinner {
  display: inline-block;
  width: 1rem;
  height: 1rem;
  border: 0.15em solid rgba(255,255,255,0.5);
  border-right-color: white;
  border-radius: 50%;
  animation: button-spinner 0.75s linear infinite;
}

@keyframes button-spinner {
  to {transform: rotate(360deg);}
}

/* FIXED: Adjusted button item styling for small screens */
@media (max-width: 576px) {
  .button-grid {
    gap: 5px;
    padding: 0 10px;
  }
  
  .button-item {
    margin-bottom: 12px;
  }
  
  .instant {
    padding: 5px;
  }
}

#buttonContainer-latest, 
#buttonContainer-trending {
  width: 75%;
  margin-left: auto;
  margin-right: auto;
}

@media (max-width: 767.98px) {
  #buttonContainer-latest, 
  #buttonContainer-trending {
    width: 95%;
  }
}