/* Glass Card Tilt Effect */
.course-wrapper {
  position: relative;
  perspective: 1500px;
  width: 100%;
  height: 100%;
  transition: transform 300ms linear;
  cursor: pointer; /* Make sure cursor shows it's clickable */
}

.course-wrapper:hover {
  transform: scale(1.03);
}

/* Tilt orientation spans for detecting mouse position */
.tilt-orientation {
  position: absolute;
  height: 33.33%;
  width: 33.33%;
  z-index: 3;
  top: 0;
  left: 0;
  pointer-events: none; /* Make sure it doesn't interfere with clicks */
}

.tilt-orientation:nth-child(2) { left: 33.33%; }
.tilt-orientation:nth-child(3) { left: 66.66%; }
.tilt-orientation:nth-child(4) { top: 33.3%; }
.tilt-orientation:nth-child(5) { top: 33.33%; left: 33.33%; }
.tilt-orientation:nth-child(6) { top: 33.33%; left: 66.66%; }
.tilt-orientation:nth-child(7) { left: 0; top: 66.66%; }
.tilt-orientation:nth-child(8) { left: 33.33%; top: 66.66%; }
.tilt-orientation:nth-child(9) { left: 66.66%; top: 66.66%; }

/* Glass card effect */
.dark-course-card {
  position: relative;
  height: 100%;
  width: 100%;
  background-color: rgba(20, 20, 30, 0.6);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: var(--card-radius);
  overflow: hidden;
  transition: transform 300ms ease-in-out;
  transform-style: preserve-3d;
  transform: rotateX(0deg) rotateY(0deg);
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.3);
  
  /* Glass effect borders */
  border-left: 1px solid rgba(255, 255, 255, 0.3);
  border-top: 1px solid rgba(255, 255, 255, 0.3);
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

/* Tilt animations on hover over different regions */
.tilt-orientation:nth-child(1):hover ~ .dark-course-card { transform: rotateX(-8deg) rotateY(8deg); }
.tilt-orientation:nth-child(2):hover ~ .dark-course-card { transform: rotateX(-12deg) rotateY(0deg); }
.tilt-orientation:nth-child(3):hover ~ .dark-course-card { transform: rotateX(-8deg) rotateY(-8deg); }
.tilt-orientation:nth-child(4):hover ~ .dark-course-card { transform: rotateX(0deg) rotateY(8deg); }
.tilt-orientation:nth-child(5):hover ~ .dark-course-card { transform: rotateX(0deg) rotateY(0deg) scale(1.05); }
.tilt-orientation:nth-child(6):hover ~ .dark-course-card { transform: rotateX(0deg) rotateY(-8deg); }
.tilt-orientation:nth-child(7):hover ~ .dark-course-card { transform: rotateX(8deg) rotateY(8deg); }
.tilt-orientation:nth-child(8):hover ~ .dark-course-card { transform: rotateX(12deg) rotateY(0deg); }
.tilt-orientation:nth-child(9):hover ~ .dark-course-card { transform: rotateX(8deg) rotateY(-8deg); }

/* Enhanced 3D depth effect for card content */
.course-image {
  width: 100%;
  height: 180px;
  position: relative;
  overflow: hidden;
  transform: translateZ(20px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.course-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.6s ease-out;
}

.course-content {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  transform: translateZ(30px);
  position: relative;
}

.course-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--dark-text-primary);
  margin-bottom: 0.6rem;
  min-height: 2.4em;
  line-height: 1.2;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  transform: translateZ(40px);
}

/* Glow effect on hover */
.course-wrapper:hover .dark-course-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: var(--card-radius);
  background: radial-gradient(
    800px circle at var(--mouse-x) var(--mouse-y), 
    rgba(255, 255, 255, 0.1),
    transparent 40%
  );
  z-index: 1;
  opacity: 0;
  animation: fadeIn 0.3s forwards;
}

/* Course badge with improved visibility */
.course-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(58, 128, 193, 0.8);
  backdrop-filter: blur(5px);
  color: white;
  padding: 4px 12px;
  border-radius: 30px;
  font-size: 0.75rem;
  font-weight: 600;
  z-index: 5;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  transform: translateZ(50px);
}

/* Animation for glow effect */
@keyframes fadeIn {
  to {
    opacity: 1;
  }
}

/* Enhanced meta information */
.course-meta {
  display: flex;
  justify-content: space-between;
  margin-bottom: 1rem;
  transform: translateZ(20px);
}

.instructor, .students {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--dark-text-secondary);
  font-size: 0.85rem;
}

/* Modernized action button */
.course-action {
  margin-top: auto;
  transform: translateZ(40px);
}

.course-action .action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
  background: rgba(58, 128, 193, 0.2);
  backdrop-filter: blur(5px);
  border-radius: 20px;
  font-weight: 500;
  color: var(--accent-color);
  transition: all 0.3s ease;
  gap: 0.5rem;
  border: 1px solid rgba(58, 128, 193, 0.3);
  width: 100%;
}

.course-action .action-button:hover {
  background: rgba(58, 128, 193, 0.3);
  transform: translateY(-2px);
}

.course-action .action-button i {
  transition: transform 0.3s ease;
}

.course-action .action-button:hover i {
  transform: translateX(3px);
}

/* Enhanced search input and category selection styles */
.dark-card-header {
  margin-bottom: 2rem;
  position: relative;
  z-index: 10;
}

/* Create a more modern glass search container */
.search-container {
  position: relative;
  margin-top: auto;
  max-width: 500px;
  margin-left: auto;
  margin-right: auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.search-icon {
  position: absolute;
  left: 13%;
  top: 45%;
  transform: translateY(-50%);
  color: var(--accent-color);
  font-size: 1.2rem;
  transition: all 0.3s ease;
  z-index: 5;
  pointer-events: none; /* Ensures clicks pass through to the input */
}

.search-input {
  width: 80%;
  padding: 1rem 1rem 1rem 3rem;
  border: none;
  border-radius: 30px;
  background-color: rgba(30, 30, 40, 0.5);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--dark-text-primary);
  font-size: 1rem;
  transition: all 0.3s ease;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1),
              0 10px 30px -10px rgba(0, 0, 0, 0.3);
  transform-style: preserve-3d;
  perspective: 1000px;
  display: block;
  margin-left: auto;
  margin-right: auto;
}
/* Add subtle 3D border effect */
.search-input::before {
  content: '';
  position: absolute;
  top: 0;
  left: 10px;
  right: 10px;
  height: 1px;
  background: linear-gradient(
    to right,
    transparent,
    rgba(255, 255, 255, 0.3),
    transparent
  );
}

.search-input:focus {
  outline: none;
  background-color: rgba(30, 30, 40, 0.7);
  box-shadow: inset 0 0 0 1px var(--accent-color),
              0 15px 35px -10px rgba(58, 128, 193, 0.3);
  transform: translateY(-2px);
}

.search-input:focus + .search-icon {
  color: var(--accent-color);
  transform: translateY(-50%) scale(1.2);
}

.search-input::placeholder {
  color: rgba(255, 255, 255, 0.5);
  transition: opacity 0.3s ease;
}

.search-input:focus::placeholder {
  opacity: 0.7;
}

/* Creative categories container with horizontal scroll */
.categories-container-scroll {
  position: relative;
  overflow: visible;
  margin-bottom: 2rem;
  padding: 0.5rem 0;
  display: flex;
  justify-content: center;
}

.categories-scroll {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE and Edge */
  scroll-behavior: smooth;
  padding: 0.5rem 0.5rem;
  position: relative;
  z-index: 2;
  /* Center alignment for category buttons */
  justify-content: center;
  margin: 0 auto;
  max-width: 90%;
}

/* Enhanced category buttons with 3D effect */
.category-btn {
  position: relative;
  background: rgba(30, 30, 40, 0.5);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--dark-text-primary); /* Changed from dark-text-secondary to dark-text-primary */
  border: none;
  border-radius: 30px;
  padding: 0.8rem 1.5rem;
  margin: 0 0.5rem;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  white-space: nowrap;
  transform-style: preserve-3d;
  perspective: 1000px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
  min-width: 120px;
  text-align: center;
  /* Add subtle light border to make outline visible */
  border: 1px solid rgba(255, 255, 255, 0.05);
}

/* Add 3D edge highlight to category buttons */
.category-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(
    to right,
    transparent,
    rgba(255, 255, 255, 0.3),
    transparent
  );
  opacity: 0.6;
}

.category-btn::after {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 1px;
  background: linear-gradient(
    to bottom,
    transparent,
    rgba(255, 255, 255, 0.2),
    transparent
  );
  opacity: 0.6;
}

/* Ensure hover state maintains white text */
.category-btn:hover {
  transform: translateY(-3px) scale(1.02);
  color: white; /* Changed from dark-text-primary to explicit white for better visibility */
  background: rgba(50, 50, 65, 0.7);
  box-shadow: 0 8px 20px rgba(76, 154, 255, 0.15);
  border: 1px solid rgba(76, 154, 255, 0.3); /* Bright blue border on hover */
}

/* Make non-active buttons slightly less bright but still visible */
.category-btn:not(.active) {
  color: rgba(255, 255, 255, 0.8); /* Slightly dimmed white for non-active buttons */
}

/* Enhanced category buttons with unbounded gradient on active state */
.category-btn.active {
  background: rgba(76, 154, 255, 0.85); /* Brighter blue */
  color: white;
  font-weight: 600;
  transform: translateY(-2px);
  box-shadow: 0 10px 25px rgba(76, 154, 255, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.2); /* Better visible border */
  position: relative;
  isolation: isolate; /* Create a new stacking context */
}

/* Make active button glow extend beyond button boundaries */
.category-btn.active::before {
  content: '';
  position: absolute;
  inset: -8px; /* Extend well beyond the button boundaries */
  background: linear-gradient(45deg, 
    rgba(76, 154, 255, 0.8), 
    rgba(76, 154, 255, 0.3),
    rgba(76, 154, 255, 0.8)
  );
  z-index: -1;
  filter: blur(12px); /* Increased blur for softer edges */
  opacity: 0.8;
  border-radius: 40px; /* Larger radius than the button */
  transform: scale(1.1); /* Make it slightly larger */
  pointer-events: none; /* Make sure it doesn't interfere with clicks */
  animation: pulseGlow 3s infinite ease-in-out;
}

/* Add animation to the glow effect */
@keyframes pulseGlow {
  0% { opacity: 0.7; transform: scale(1.05); }
  50% { opacity: 0.9; transform: scale(1.15); }
  100% { opacity: 0.7; transform: scale(1.05); }
}

/* Brighter icon color for better visibility */
.category-btn i {
  color: rgba(255, 255, 255, 0.9); /* Updated from blue to white with high opacity */
  margin-right: 0.5rem;
  font-size: 1rem;
  transition: all 0.3s ease;
}

.category-btn.active i {
  color: white;
}

/* Keep hover state consistent with button text */
.category-btn:hover i {
  color: white; /* Changed to pure white on hover */
  transform: scale(1.15);
}

/* Custom left and right scroll indicators */
.categories-container-scroll {
  position: relative;
}

.scroll-indicator-left,
.scroll-indicator-right {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(30, 30, 45, 0.8);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  cursor: pointer;
  z-index: 10; /* Higher z-index to ensure visibility */
  opacity: 0;
  transition: all 0.3s ease;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1); /* Subtle border */
}

.scroll-indicator-left {
  left: 0;
}

.scroll-indicator-right {
  right: 0;
}

.categories-container-scroll:hover .scroll-indicator-left,
.categories-container-scroll:hover .scroll-indicator-right {
  opacity: 0.8;
}

/* Brighter hover state for scroll indicators */
.scroll-indicator-left:hover,
.scroll-indicator-right:hover {
  opacity: 1;
  background: rgba(76, 154, 255, 0.9); /* Brighter blue */
  transform: translateY(-50%) scale(1.1);
  box-shadow: 0 5px 15px rgba(76, 154, 255, 0.4);
}

/* Make sure the link spans the entire card */
.card-link {
  position: relative;
  display: block;
  height: 100%;
  width: 100%;
  text-decoration: none;
  color: inherit;
  z-index: 2; /* Ensure link is above other elements */
}

/* Additional mobile responsiveness for course cards */
@media (max-width: 767.98px) {
  .dark-course-card {
    /* ...existing properties... */
    transform: none !important; /* Disable complex transforms on mobile */
  }
  
  /* Disable hover effects on mobile that might cause issues */
  .tilt-orientation:hover ~ .dark-course-card {
    transform: none !important;
  }
  
  /* Simplify animations for better performance */
  .course-wrapper:hover {
    transform: translateY(-5px); /* Simpler transform for mobile */
  }
  
  /* Make course content more compact */
  .course-content {
    padding: 1rem; /* Less padding */
  }
  
  .course-title {
    font-size: 1rem; /* Smaller font */
    min-height: 2.2em; /* Shorter min-height */
  }
  
  .course-image {
    height: 160px; /* Shorter image height */
  }
}
