/* ========================================
   AIMagicTools - Final Fixes & Optimizations
   Responsive & RTL Enhancements
======================================== */

/* === Prevent Horizontal Overflow === */
html, body {
  max-width: 100vw;
  overflow-x: hidden;
}

* {
  max-width: 100%;
}

/* === Hero Visual Overflow Fix === */
.hero-visual {
  max-width: 100%;
  overflow: visible;
}

/* === Better Mobile Spacing === */
@media (max-width: 480px) {
  .hero-content h1 {
    font-size: 1.75rem;
    line-height: 1.3;
  }
  
  .hero-content p {
    font-size: 0.95rem;
  }
  
  .card-title {
    font-size: 1.125rem;
  }
  
  .card-description {
    font-size: 0.9rem;
  }
}

/* === Fix FAQ on Small Screens === */
@media (max-width: 480px) {
  .faq-question {
    font-size: 1rem;
    padding: var(--spacing-sm) var(--spacing-md);
  }
  
  .faq-answer-content {
    font-size: 0.9rem;
    padding: 0 var(--spacing-md) var(--spacing-sm);
  }
}

/* === Auth Forms Mobile === */
@media (max-width: 480px) {
  .auth-card {
    padding: var(--spacing-lg);
  }
  
  .auth-header h1 {
    font-size: 1.5rem;
  }
}

/* === Contact Page Grid Fix === */
@media (max-width: 768px) {
  .contact-grid {
    grid-template-columns: 1fr !important;
  }
}

/* === Better RTL Support for Icons === */
.bi::before {
  display: inline-block;
}

/* === Toast RTL Fix === */
.toast {
  direction: rtl;
  text-align: right;
}

/* === Smooth Font Rendering === */
body {
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* === Better Focus States === */
*:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* === Loading State for Images === */
img {
  display: block;
  max-width: 100%;
  height: auto;
}

/* === Better Link Hover in Footer === */
.footer-links a {
  display: inline-block;
  transition: all var(--transition-base);
}

.footer-links a:hover {
  transform: translateX(-5px);
  color: var(--white);
}

/* === Button Active State === */
.btn:active {
  transform: translateY(0) scale(0.98);
}

/* === Card Border Enhancement === */
.card {
  will-change: transform;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* === Better Shadow on Dark Backgrounds === */
.hero .btn {
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.hero .btn:hover {
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}

/* === Feature Icon Responsive === */
@media (max-width: 480px) {
  .feature-icon {
    width: 60px;
    height: 60px;
    font-size: 1.5rem;
  }
  
  .step-number {
    width: 60px;
    height: 60px;
    font-size: 1.5rem;
  }
}

/* === Better Spacing for Small Screens === */
@media (max-width: 480px) {
  :root {
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;
    --spacing-3xl: 4rem;
  }
}

/* === Improve Readability on Small Screens === */
@media (max-width: 480px) {
  p {
    font-size: 0.95rem;
    line-height: 1.7;
  }
}

/* === Menu Toggle Animation Enhancement === */
.menu-toggle.active span:nth-child(1) {
  transform: rotate(45deg) translate(6px, 6px);
}

.menu-toggle.active span:nth-child(3) {
  transform: rotate(-45deg) translate(6px, -6px);
}

/* === Better Grid Gaps on Mobile === */
@media (max-width: 768px) {
  .services-grid,
  .features-grid {
    gap: var(--spacing-md);
  }
}

/* === Navbar Backdrop === */
.nav.active {
  backdrop-filter: blur(10px);
  background: rgba(255, 255, 255, 0.98);
}

/* === Fix for Very Small Screens === */
@media (max-width: 360px) {
  .container {
    padding: 0 1rem;
  }
  
  .btn {
    padding: 0.75rem 1.25rem;
    font-size: 0.875rem;
  }
  
  h1 {
    font-size: 1.75rem;
  }
  
  h2 {
    font-size: 1.5rem;
  }
}

/* === Print Styles === */
@media print {
  .header,
  .nav,
  .menu-toggle,
  .hero-actions,
  .cta-section,
  .footer,
  #particleCanvas,
  .magic-cursor,
  .magic-cursor-trail {
    display: none !important;
  }
  
  body {
    background: white;
    color: black;
  }
}

/* === Dark Mode Preparation (Future) === */
@media (prefers-color-scheme: dark) {
  /* Currently disabled, but structure is ready */
  /* Add dark mode styles here when needed */
}

/* === Better Performance === */
.card,
.btn,
.feature-card,
.step {
  will-change: transform;
}

/* After animation completes */
.card.revealed,
.feature-card.revealed,
.step.revealed {
  will-change: auto;
}
