/* CSS Fixes for SmartGoogleSearch */

/* Fix dropdown menu background and text in dark mode */
[data-theme="dark"] .dropdown-menu {
  border: 1px solid var(--gray-600);
  background-color: var(--gray-800) !important;
}

/* Fix form controls in dark mode */
[data-theme="dark"] .form-control,
[data-theme="dark"] input[type="text"],
[data-theme="dark"] input[type="search"],
[data-theme="dark"] input[type="email"],
[data-theme="dark"] input[type="password"],
[data-theme="dark"] input[type="number"],
[data-theme="dark"] input[type="tel"],
[data-theme="dark"] input[type="url"],
[data-theme="dark"] input[type="date"],
[data-theme="dark"] input[type="datetime-local"],
[data-theme="dark"] input[type="month"],
[data-theme="dark"] input[type="week"],
[data-theme="dark"] input[type="time"],
[data-theme="dark"] input[type="color"],
[data-theme="dark"] input:not([type]),
[data-theme="dark"] textarea,
[data-theme="dark"] select {
  background-color: var(--gray-800, #1e2130) !important;
  color: white !important;
  border-color: var(--gray-600, #4a5568) !important;
}

/* Enhanced Popular Searches Section to match Course Shortcuts */
.popular-searches-section {
  padding: 4rem 0;
  background: var(--bg-secondary);
  position: relative;
  overflow: hidden;
  border-top: 1px solid rgba(var(--border-rgb), 0.1);
  border-bottom: 1px solid rgba(var(--border-rgb), 0.1);
}

.popular-searches-section::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    135deg,
    rgba(var(--primary-50-rgb), 0.15) 0%,
    rgba(var(--primary-100-rgb), 0.05) 100%
  );
  z-index: 0;
}

/* Match section header style with course shortcuts */
.popular-searches-section .section-header h2 {
  text-align: center;
  margin-bottom: 1rem;
  color: var(--text-primary);
  font-size: 2.5rem;
}

.popular-searches-section .section-icon {
  margin-right: 0.5rem;
  color: var(--accent-primary);
  font-size: 2rem;
}

.popular-searches-section .section-subtitle {
  text-align: center;
  color: var(--text-secondary);
  margin-bottom: 3rem;
  font-size: 1.1rem;
  max-width: 700px;
  margin-left: auto;
  margin-right: auto;
}

/* Match grid layout with course shortcuts */
.popular-search-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 2rem;
  padding: 0 1rem;
  position: relative;
  z-index: 1;
}

/* Enhance each search item to match course card style */
.popular-search-item {
  background: var(--bg-primary);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  border: 1px solid var(--border-color);
  position: relative;
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  animation: cardEntrance 0.6s ease-out;
  animation-fill-mode: backwards;
}

.popular-search-item:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 15px rgba(0, 0, 0, 0.1);
}

/* Match icon style with course icon */
.search-icon {
  width: 50px;
  height: 50px;
  background: var(--accent-primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
}

.search-icon i {
  font-size: 1.5rem;
  color: white;
  transition: transform 0.3s ease, color 0.3s ease;
}

.popular-search-item:hover .search-icon i {
  transform: scale(1.2);
}

/* Match text styling with course card */
.search-text {
  color: var(--text-primary);
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
  font-weight: 600;
  line-height: 1.4;
  position: relative;
}

.search-text::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 0;
  height: 2px;
  background-color: var(--accent-primary);
  transition: width 0.3s ease;
}

.popular-search-item:hover .search-text::after {
  width: 100%;
}

.search-category {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* Match button style with course styles */
.popular-search-navigation {
  display: flex;
  justify-content: center;
  margin-top: 2.5rem;
}

.view-more-btn {
  padding: 0.75rem 1.5rem;
  background: transparent;
  color: var(--accent-primary);
  border: 2px solid var(--accent-primary);
  border-radius: 2rem;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.view-more-btn:hover {
  background: var(--accent-primary);
  color: white;
  transform: translateY(-3px);
  box-shadow: 0 4px 12px rgba(var(--primary-500-rgb), 0.25);
}

.view-more-btn i {
  font-size: 1.2rem;
}

/* Dark mode enhancements */
[data-theme="dark"] .popular-searches-section {
  background: var(--gray-900, #111827);
  border-top: 1px solid rgba(var(--primary-300-rgb), 0.1);
  border-bottom: 1px solid rgba(var(--primary-300-rgb), 0.1);
}

[data-theme="dark"] .popular-searches-section::before {
  background: linear-gradient(
    135deg,
    rgba(var(--primary-900-rgb), 0.3) 0%,
    rgba(var(--primary-800-rgb), 0.1) 100%
  );
}

[data-theme="dark"] .popular-search-item {
  background: var(--gray-800, #1e2130);
  border: 1px solid rgba(var(--primary-300-rgb), 0.1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

[data-theme="dark"] .popular-search-item:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  border-color: rgba(var(--primary-400-rgb), 0.4);
}

[data-theme="dark"] .search-icon {
  background: var(--primary-600);
  box-shadow: 0 0 15px rgba(var(--primary-500-rgb), 0.15);
}

[data-theme="dark"] .search-text {
  color: white;
}

[data-theme="dark"] .search-category {
  color: var(--gray-400);
}

[data-theme="dark"] .view-more-btn {
  color: var(--primary-300);
  border: 2px solid var(--primary-600);
  background: rgba(var(--primary-900-rgb), 0.3);
}

[data-theme="dark"] .view-more-btn:hover {
  background: var(--primary-600);
  color: white;
  box-shadow: 0 4px 15px rgba(var(--primary-400-rgb), 0.3);
  border-color: var(--primary-500);
}

/* Animations for popular search items */
.popular-search-item:nth-child(1) { animation-delay: 0.1s; }
.popular-search-item:nth-child(2) { animation-delay: 0.2s; }
.popular-search-item:nth-child(3) { animation-delay: 0.3s; }
.popular-search-item:nth-child(4) { animation-delay: 0.4s; }
.popular-search-item:nth-child(5) { animation-delay: 0.5s; }
.popular-search-item:nth-child(6) { animation-delay: 0.6s; }
.popular-search-item:nth-child(7) { animation-delay: 0.7s; }
.popular-search-item:nth-child(8) { animation-delay: 0.8s; }

/* Dark mode specific animations */
[data-theme="dark"] .search-text::after {
  background-color: var(--primary-400);
}

[data-theme="dark"] .popular-search-item:hover .search-icon i {
  color: white;
  transform: scale(1.2) rotate(5deg);
}

/* Responsive adjustments matching course shortcuts */
@media (max-width: 1200px) {
  .popular-search-grid {
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1.25rem;
  }
}

@media (max-width: 768px) {
  .popular-searches-section {
    padding: 2rem 0;
  }

  .popular-searches-section .section-header h2 {
    font-size: 2rem;
  }

  .popular-search-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .popular-search-item {
    padding: 1.2rem;
  }

  .search-text {
    font-size: 1rem;
  }

  /* Improve mobile menu container */
  .nav-links {
    background-color: var(--bg-color);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    padding: 1rem 0;
    transform: translateY(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
    opacity: 0;
    will-change: transform, opacity;
    max-height: 85vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    display: none; /* Ensure it's not visible by default */
  }

  /* Fix animation when menu opens */
  .nav-links.open {
    transform: translateY(0);
    opacity: 1;
    display: flex; /* Ensure it's displayed when open */
  }

  /* Improve dropdown indicators */
  .nav-links .dropdown > a i.fa-caret-down {
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    width: 28px;
    height: 28px;
    line-height: 28px;
    text-align: center;
    margin-left: 8px;
    background-color: rgba(255, 255, 255, 0.15);
    transition: transform 0.3s ease, background-color 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  /* Fix dropdown indicator for dark mode */
  [data-theme="dark"] .nav-links .dropdown > a i.fa-caret-down {
    border-color: rgba(255, 255, 255, 0.2);
    background-color: rgba(0, 0, 0, 0.3);
    color: var(--gray-300);
  }

  /* Animate dropdown indicator rotation */
  .nav-links .dropdown.open > a i.fa-caret-down {
    transform: rotate(180deg);
    background-color: var(--primary-500);
    border-color: var(--primary-600);
    color: white;
  }

  /* Improve dropdown menu appearance */
  .nav-links .dropdown-menu {
    background-color: rgba(0, 0, 0, 0.03);
    border-radius: 8px;
    margin: 5px 15px 5px 25px;
    box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.05);
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease;
    padding: 0;
    position: relative;
    z-index: 1;
  }

  /* Fix dropdown menu for dark mode */
  [data-theme="dark"] .nav-links .dropdown-menu {
    background-color: rgba(255, 255, 255, 0.05);
    box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.1);
  }

  /* Fix dropdown menu when open */
  .nav-links .dropdown.open .dropdown-menu {
    max-height: 300px;
    padding: 8px 0;
  }

  /* Improve touch targets for all interactive elements */
  .nav-links a,
  .nav-links button,
  .mobile-menu-btn,
  .theme-toggle,
  .dropdown-menu a {
    min-height: 48px;
    min-width: 48px;
    padding: 12px 16px;
    touch-action: manipulation;
    display: flex;
    align-items: center;
  }

  /* Adapt hover effects for touch devices */
  @media (hover: hover) {
    .nav-links a:hover,
    .dropdown-menu a:hover {
      background-color: rgba(0, 0, 0, 0.05);
    }
    
    [data-theme="dark"] .nav-links a:hover,
    [data-theme="dark"] .dropdown-menu a:hover {
      background-color: rgba(255, 255, 255, 0.05);
    }
  }

  /* Active state for touch devices */
  .nav-links a:active,
  .dropdown-menu a:active {
    background-color: rgba(var(--primary-500-rgb), 0.1);
  }
  
  [data-theme="dark"] .nav-links a:active,
  [data-theme="dark"] .dropdown-menu a:active {
    background-color: rgba(var(--primary-400-rgb), 0.15);
  }

  /* Add visible spacing between menu items */
  .nav-links li:not(:last-child) {
    margin-bottom: 4px;
  }

  /* Improve nav-links list item appearance */
  .nav-links li {
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    transition-delay: 0s;
  }

  /* Animate list items when menu opens */
  .nav-links.open li {
    opacity: 1;
    transform: translateY(0);
  }

  /* Stagger animation for menu items */
  .nav-links.open li:nth-child(1) { transition-delay: 0.05s; }
  .nav-links.open li:nth-child(2) { transition-delay: 0.1s; }
  .nav-links.open li:nth-child(3) { transition-delay: 0.15s; }
  .nav-links.open li:nth-child(4) { transition-delay: 0.2s; }
  .nav-links.open li:nth-child(5) { transition-delay: 0.25s; }
  .nav-links.open li:nth-child(6) { transition-delay: 0.3s; }

  /* Add touch feedback effects */
  .nav-links a:active,
  .mobile-menu-btn:active,
  .theme-toggle:active,
  .tool-action-btn:active,
  .btn:active {
    transform: scale(0.96);
    transition: transform 0.1s;
  }

  /* Fix mobile-menu-btn appearance */
  .mobile-menu-btn {
    padding: 0;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    z-index: 1010;
  }

  /* Improve visual feedback when menu button is active */
  .mobile-menu-btn.active {
    color: var(--primary-500);
  }

  /* Add visual indicator when menu is open */
  .mobile-menu-btn.active::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(var(--primary-500-rgb), 0.1);
    transform: translate(-50%, -50%);
    z-index: -1;
  }
}

@media (max-width: 576px) {
  .popular-search-grid {
    grid-template-columns: 1fr;
    max-width: 100%;
    gap: 1rem;
  }

  .popular-search-item {
    padding: 1.25rem;
  }

  .search-icon {
    width: 40px;
    height: 40px;
  }
  
  .search-icon i {
    font-size: 1.2rem;
  }
}

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

@media (prefers-reduced-motion: reduce) {
  .popular-search-item {
    animation: none;
  }
  
  .popular-search-item:hover {
    transform: none;
  }
  
  .popular-search-item:hover .search-icon i {
    transform: none;
  }
  
  .search-text::after {
    transition: none;
  }
}

/* Style for the arrow indicator */
.search-arrow {
  position: absolute;
  top: 50%;
  right: 1.5rem;
  transform: translateY(-50%);
  opacity: 0;
  transition: all 0.3s ease;
}

.search-arrow i {
  color: var(--accent-primary);
  font-size: 1.1rem;
}

.popular-search-item {
  position: relative;
}

.popular-search-item:hover .search-arrow {
  opacity: 1;
  right: 1rem;
}

[data-theme="dark"] .search-arrow i {
  color: var(--primary-400);
}

@media (max-width: 576px) {
  .search-arrow {
    right: 1rem;
  }
  
  .popular-search-item:hover .search-arrow {
    right: 0.75rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .search-arrow {
    transition: none;
  }
}

/* Fix AI Query Optimization modal text visibility in dark mode */
[data-theme="dark"] .ai-query-optimization-modal {
  color: var(--text-primary);
}

[data-theme="dark"] .ai-query-optimization-modal div {
  background-color: var(--gray-800);
}

[data-theme="dark"] .ai-query-optimization-modal div div {
  background-color: var(--gray-900);
  color: white;
  border-color: var(--gray-700);
}

[data-theme="dark"] .ai-query-optimization-modal h2,
[data-theme="dark"] .ai-query-optimization-modal h3,
[data-theme="dark"] .ai-query-optimization-modal h4 {
  color: var(--primary-300);
}

[data-theme="dark"] .ai-query-optimization-modal span,
[data-theme="dark"] .ai-query-optimization-modal li,
[data-theme="dark"] .ai-query-optimization-modal strong {
  color: white;
}

[data-theme="dark"] .ai-query-optimization-modal button.btn-secondary {
  background-color: var(--gray-700);
  color: white;
}

/* Direct fix for query modal text fields */
[data-theme="dark"] [style*="position: fixed"][style*="z-index: 10000"] > div {
  background-color: var(--gray-800);
  color: white;
}

[data-theme="dark"] [style*="position: fixed"][style*="z-index: 10000"] div div[style*="background: #fff"] {
  background-color: var(--gray-900) !important;
  color: white !important;
  border-color: var(--gray-700) !important;
}

[data-theme="dark"] [style*="position: fixed"][style*="z-index: 10000"] h2 {
  color: var(--primary-300) !important;
}

[data-theme="dark"] [style*="position: fixed"][style*="z-index: 10000"] h4 {
  color: var(--primary-300) !important;
}

[data-theme="dark"] [style*="position: fixed"][style*="z-index: 10000"] div[style*="background: #f8fafc"] {
  background-color: var(--gray-800) !important;
  border-color: var(--gray-700) !important;
}

[data-theme="dark"] [style*="position: fixed"][style*="z-index: 10000"] span[style*="color: #475569"] {
  color: var(--primary-300) !important;
}

[data-theme="dark"] [style*="position: fixed"][style*="z-index: 10000"] div[style*="color: #64748b"] {
  color: var(--gray-300) !important;
}

[data-theme="dark"] [style*="position: fixed"][style*="z-index: 10000"] div[style*="color: #10b981"] {
  color: var(--primary-400) !important;
}

[data-theme="dark"] [style*="position: fixed"][style*="z-index: 10000"] h3[style*="color: #475569"] {
  color: var(--primary-300) !important;
  border-color: var(--gray-700) !important;
}

[data-theme="dark"] [style*="position: fixed"][style*="z-index: 10000"] li strong {
  color: var(--primary-300) !important;
}

[data-theme="dark"] [style*="position: fixed"][style*="z-index: 10000"] li span {
  color: var(--gray-300) !important;
}

[data-theme="dark"] [style*="position: fixed"][style*="z-index: 10000"] button.btn-secondary {
  background-color: var(--gray-700) !important;
  color: white !important;
}

/* Additional fixes for the AI Query Optimization modal content in dark mode */
[data-theme="dark"] [style*="position: fixed"][style*="z-index: 10000"] > div > div {
  background-color: var(--gray-800) !important;
  color: white;
}

[data-theme="dark"] [style*="position: fixed"][style*="z-index: 10000"] button.btn-primary {
  background-color: var(--primary-600) !important;
  color: white !important;
  box-shadow: 0 4px 6px rgba(var(--primary-500-rgb), 0.3) !important;
}

[data-theme="dark"] [style*="position: fixed"][style*="z-index: 10000"] button.btn-primary:hover {
  background-color: var(--primary-500) !important;
  box-shadow: 0 4px 12px rgba(var(--primary-400-rgb), 0.4) !important;
}

[data-theme="dark"] [style*="position: fixed"][style*="z-index: 10000"] div[style*="border-left: 4px solid #10b981"] {
  border-left-color: var(--primary-500) !important;
}

[data-theme="dark"] [style*="position: fixed"][style*="z-index: 10000"] h4[style*="color: #10b981"] {
  color: var(--primary-400) !important;
}

/* Fix research feature buttons clickability in dark mode */
[data-theme="dark"] .research-feature-btn {
  background-color: rgba(30, 41, 59, 0.5);
  color: var(--text-color, white);
  border: 1px solid var(--gray-600, #4a5568);
  position: relative;
  z-index: 10;
  cursor: pointer;
  transition: all 0.3s ease;
}

[data-theme="dark"] .research-feature-btn:hover {
  background-color: var(--primary-600, #c2410c);
  color: white;
  border-color: var(--primary-500, #f97316);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

[data-theme="dark"] .research-feature-btn:hover::before {
  width: 100%;
}

[data-theme="dark"] .research-feature-btn:hover span {
  transform: translateX(-8px);
}

[data-theme="dark"] .research-feature-btn:hover i {
  transform: translateX(5px);
  opacity: 1;
}

/* Improve overall button contrast in dark mode */
[data-theme="dark"] button,
[data-theme="dark"] .btn {
  position: relative;
  z-index: 10;
}

/* Improve dark mode card contrast */
[data-theme="dark"] .research-feature-card,
[data-theme="dark"] .card {
  background-color: var(--gray-800, #1e2130);
  border: 1px solid var(--gray-700, #2d3748);
}

[data-theme="dark"] .research-feature-card:hover,
[data-theme="dark"] .card:hover {
  border-color: var(--primary-500, #f97316);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

/* Improve text readability in dark mode */
[data-theme="dark"] .research-feature-card h3,
[data-theme="dark"] h1, 
[data-theme="dark"] h2, 
[data-theme="dark"] h3, 
[data-theme="dark"] h4, 
[data-theme="dark"] h5, 
[data-theme="dark"] h6 {
  color: var(--text-color, white);
}

[data-theme="dark"] .research-feature-card p,
[data-theme="dark"] p,
[data-theme="dark"] li,
[data-theme="dark"] span:not(.badge):not([class*="color"]) {
  color: var(--gray-300, #d1d5db);
}

/* Fix SVG and icon visibility in dark mode */
[data-theme="dark"] svg,
[data-theme="dark"] i:not(.fa-moon):not(.fa-sun) {
  color: var(--gray-300, #d1d5db);
}

/* Additional fixes for interactive elements and focus states */
[data-theme="dark"] button:focus,
[data-theme="dark"] a:focus,
[data-theme="dark"] input:focus,
[data-theme="dark"] select:focus,
[data-theme="dark"] textarea:focus {
  outline: 2px solid var(--primary-400, #60a5fa);
  outline-offset: 2px;
}

/* Ensure consistent focus visibility */
:focus-visible {
  outline: 2px solid var(--primary-500, #3b82f6);
  outline-offset: 2px;
}

[data-theme="dark"] :focus-visible {
  outline-color: var(--primary-400, #60a5fa);
}

/* Improve interactive element states */
[data-theme="dark"] .btn:hover,
[data-theme="dark"] button:hover:not([disabled]) {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

[data-theme="dark"] .btn:active,
[data-theme="dark"] button:active:not([disabled]) {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Fix dropdown menu items */
[data-theme="dark"] .dropdown-menu a,
[data-theme="dark"] .dropdown-item {
  color: var(--text-color, white);
}

[data-theme="dark"] .dropdown-menu a:hover,
[data-theme="dark"] .dropdown-item:hover {
  background-color: var(--gray-700, #2d3748);
  color: white;
}

/* Fix form element placeholder text */
[data-theme="dark"] input::placeholder,
[data-theme="dark"] textarea::placeholder {
  color: var(--gray-500, #6b7280) !important;
}

/* Ensure proper contrast for disabled elements */
[data-theme="dark"] button:disabled,
[data-theme="dark"] input:disabled,
[data-theme="dark"] select:disabled,
[data-theme="dark"] textarea:disabled,
[data-theme="dark"] .btn:disabled {
  background-color: var(--gray-700, #2d3748) !important;
  color: var(--gray-400, #9ca3af) !important;
  border-color: var(--gray-600, #4a5568) !important;
  cursor: not-allowed;
  opacity: 0.7;
}

/* Fix notification colors in dark mode */
[data-theme="dark"] .notification,
[data-theme="dark"] .toast,
[data-theme="dark"] .alert {
  background-color: var(--gray-800, #1e2130);
  color: var(--text-color, white);
  border-color: var(--gray-700, #2d3748);
}

/* Improve radio and checkbox visibility */
[data-theme="dark"] input[type="checkbox"],
[data-theme="dark"] input[type="radio"] {
  background-color: var(--gray-700, #2d3748);
  border-color: var(--gray-600, #4a5568);
}

[data-theme="dark"] input[type="checkbox"]:checked,
[data-theme="dark"] input[type="radio"]:checked {
  background-color: var(--primary-500, #3b82f6);
  border-color: var(--primary-600, #2563eb);
}

/* SmartGoogleSearch Responsive Improvements */

/* Tablet-specific styles (768px-1024px) */
@media (min-width: 768px) and (max-width: 1024px) {
  /* Optimize container widths for tablets */
  .container {
    width: 90%;
    max-width: 940px;
  }
  
  /* Adjust card grid for better tablet display */
  .article-grid,
  .features-grid,
  .popular-search-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
  }
  
  /* Optimize form layouts for tablets */
  .tool-filters-row {
    flex-wrap: nowrap;
  }
  
  .tool-filter {
    flex: 1;
    min-width: 0; /* Allow shrinking below content size */
  }
  
  /* Slightly reduce font size on tablets for more content */
  h1 { font-size: clamp(1.8rem, 4vw, 2.5rem); }
  h2 { font-size: clamp(1.5rem, 3vw, 2rem); }
}

/* Optimize animations for better performance */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.1s !important;
    transition-duration: 0.1s !important;
  }
}

/* Ripple effect styles */
.ripple {
  position: relative;
  overflow: hidden;
  transform: translate3d(0, 0, 0);
}

.ripple-effect {
  position: absolute;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.4);
  pointer-events: none;
  transform: scale(0);
  animation: ripple-animation 0.6s linear;
  z-index: 0;
}

[data-theme="dark"] .ripple-effect {
  background-color: rgba(255, 255, 255, 0.2);
}

@keyframes ripple-animation {
  to {
    transform: scale(2);
    opacity: 0;
  }
}

/* Fix button focus states */
button:focus-visible,
a:focus-visible,
.mobile-menu-btn:focus-visible,
.theme-toggle:focus-visible {
  outline: 2px solid var(--primary-500);
  outline-offset: 2px;
}

[data-theme="dark"] button:focus-visible,
[data-theme="dark"] a:focus-visible,
[data-theme="dark"] .mobile-menu-btn:focus-visible,
[data-theme="dark"] .theme-toggle:focus-visible {
  outline-color: var(--primary-400);
}

/* Fix excessive horizontal scrolling on small screens */
@media (max-width: 360px) {
  .container {
    width: 100%;
    padding-left: 10px;
    padding-right: 10px;
    overflow-x: hidden;
  }
  
  .header {
    overflow-x: hidden;
  }
  
  body {
    overflow-x: hidden;
    max-width: 100%;
  }
  
  .nav {
    padding: 0 5px;
  }
}

/* Reduce animation for users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
  .nav-links,
  .nav-links.open,
  .nav-links li,
  .nav-links.open li,
  .nav-links .dropdown > a i.fa-caret-down,
  .nav-links .dropdown.open > a i.fa-caret-down {
    transition-duration: 0.1s !important;
    animation-duration: 0.1s !important;
  }
  
  .nav-links .dropdown-menu {
    transition: none !important;
  }
}

/* Scroll-to-top button styles */
.scroll-to-top {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background-color: var(--primary-500);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 999;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px);
  transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease, background-color 0.3s ease;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
  border: none;
}

.scroll-to-top.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.scroll-to-top:hover {
  background-color: var(--primary-600);
  transform: translateY(-5px);
  box-shadow: 0 6px 15px rgba(0, 0, 0, 0.25);
}

.scroll-to-top:active {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.scroll-to-top i {
  font-size: 1.4rem;
  color: white;
}

/* Dark mode styles for scroll-to-top button */
[data-theme="dark"] .scroll-to-top {
  background-color: var(--primary-600);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .scroll-to-top:hover {
  background-color: var(--primary-500);
  box-shadow: 0 6px 15px rgba(0, 0, 0, 0.4);
}

/* Responsive styles for scroll-to-top button */
@media (max-width: 768px) {
  .scroll-to-top {
    width: 45px;
    height: 45px;
    bottom: 20px;
    right: 20px;
  }
}

@media (max-width: 480px) {
  .scroll-to-top {
    width: 40px;
    height: 40px;
    bottom: 15px;
    right: 15px;
  }
  
  .scroll-to-top i {
    font-size: 1.2rem;
  }
}

/* Reduce motion for those who prefer it */
@media (prefers-reduced-motion: reduce) {
  .scroll-to-top {
    transition: opacity 0.1s ease, visibility 0.1s ease, background-color 0.1s ease;
  }
  
  .scroll-to-top:hover {
    transform: none;
  }
} 