/* ==========================================
   CLEAN OVERFLOW PREVENTION
   ========================================== */

html {
  scroll-behavior: smooth;
}

body {
  overflow-x: hidden;
  position: relative;
  font-family:
    -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue',
    Arial, sans-serif;
  line-height: 1.6;
  margin: 0;
  padding: 0;
}

* {
  box-sizing: border-box;
}

/* Prevent media from overflowing */
img,
video,
iframe,
svg {
  max-width: 100%;
  height: auto;
}

/* Container fixes */
nav,
section,
.container {
  max-width: 100%;
}

/* ==========================================
   RTL SUPPORT
   ========================================== */

body[dir='rtl'] {
  direction: rtl;
  text-align: right;
}

/* RTL: Text alignment */
body[dir='rtl'] .text-left {
  text-align: right;
}

body[dir='rtl'] .text-right {
  text-align: left;
}

/* RTL: Border flipping */
body[dir='rtl'] .border-l {
  border-left-width: 0;
  border-right-width: 1px;
}

body[dir='rtl'] .border-l-4 {
  border-left-width: 0;
  border-right-width: 4px;
}

/* RTL: Navigation links spacing */
body[dir='rtl'] .space-x-8 > :not([hidden]) ~ :not([hidden]) {
  --tw-space-x-reverse: 0;
  margin-right: calc(2rem * var(--tw-space-x-reverse));
  margin-left: calc(2rem * calc(1 - var(--tw-space-x-reverse)));
}

body[dir='rtl'] .space-x-8 > * + * {
  margin-left: 0 !important;
  margin-right: 2rem !important;
}

body[dir='rtl'] .space-x-4 > * + * {
  margin-left: 0 !important;
  margin-right: 1rem !important;
}

body[dir='rtl'] .space-x-2 > * + * {
  margin-left: 0 !important;
  margin-right: 0.5rem !important;
}

/* RTL: Navigation padding/margin */
body[dir='rtl'] nav .ml-4 {
  margin-left: 0;
  margin-right: 1rem;
}

body[dir='rtl'] nav .pl-4 {
  padding-left: 0;
  padding-right: 1rem;
}

/* RTL: Icon spacing in flex containers */
body[dir='rtl'] .flex .mr-4 {
  margin-right: 0;
  margin-left: 1rem;
}

/* RTL: Form inputs */
body[dir='rtl'] input,
body[dir='rtl'] textarea {
  text-align: right;
}

body[dir='rtl'] ::placeholder {
  text-align: right;
}

/* RTL: Phone numbers - KEEP LTR */
body[dir='rtl'] a[href^='tel:'],
body[dir='rtl'] a[href^='https://wa.me'] {
  direction: ltr;
  unicode-bidi: embed;
}

/* RTL: Back to top button */
body[dir='rtl'] #back-to-top {
  right: auto;
  left: 1rem;
}

/* ==========================================
   BACK TO TOP BUTTON
   ========================================== */

#back-to-top {
  right: 1rem;
  max-width: 48px;
  max-height: 48px;
}

/* ==========================================
   GENERAL STYLES
   ========================================== */

/* Smooth Transitions */
a,
button {
  transition: all 0.3s ease;
}

/* Active Language Button */
.lang-btn.active {
  background-color: #006747;
  color: white;
  font-weight: 600;
}

/* Form Focus States */
input:focus,
textarea:focus,
select:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(0, 103, 71, 0.1);
}

/* Navbar Scroll Effect */
#navbar.scrolled {
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* Hover Effects */
.hover-scale:hover {
  transform: scale(1.05);
}

/* Loading Animation */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.animate-spin {
  animation: spin 1s linear infinite;
}

/* ==========================================
   ANIMATION DELAYS
   ========================================== */

.delay-100 {
  animation-delay: 100ms;
}

.delay-200 {
  animation-delay: 200ms;
}

.delay-300 {
  animation-delay: 300ms;
}

/* ==========================================
   GRADIENT TEXT
   ========================================== */

.gradient-text {
  background: linear-gradient(135deg, #006747 0%, #3b7a57 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ==========================================
   CARD HOVER EFFECT
   ========================================== */

.card-hover {
  transition: all 0.3s ease;
}

.card-hover:hover {
  transform: translateY(-8px);
  box-shadow:
    0 20px 25px -5px rgba(0, 0, 0, 0.1),
    0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

/* ==========================================
   BUTTON RIPPLE EFFECT
   ========================================== */

.btn-primary,
.btn-secondary {
  position: relative;
  overflow: hidden;
}

.btn-primary::before,
.btn-secondary::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transform: translate(-50%, -50%);
  transition:
    width 0.6s,
    height 0.6s;
}

.btn-primary:hover::before,
.btn-secondary:hover::before {
  width: 300px;
  height: 300px;
}

/* ==========================================
   MOBILE MENU ANIMATION
   ========================================== */

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

#mobile-menu {
  animation: slideDown 0.3s ease;
}

/* ==========================================
   ACCESSIBILITY
   ========================================== */

/* Focus Visible */
*:focus-visible {
  outline: 2px solid #006747;
  outline-offset: 2px;
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ==========================================
   PRINT STYLES
   ========================================== */

@media print {
  nav,
  footer,
  .no-print {
    display: none;
  }
}

/* ==========================================
   MOBILE RESPONSIVE FIXES
   ========================================== */

@media (max-width: 768px) {
  /* Ensure no horizontal scroll */
  body {
    overflow-x: hidden;
  }

  /* Responsive padding */
  nav .container,
  section .container {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  /* Prevent text overflow */
  h1,
  h2,
  h3,
  h4,
  h5,
  h6,
  p {
    word-wrap: break-word;
    overflow-wrap: break-word;
  }

  /* Back to top button mobile positioning */
  #back-to-top {
    bottom: 1rem;
    right: 1rem;
  }

  body[dir='rtl'] #back-to-top {
    left: 1rem;
    right: auto;
  }

  /* Disable problematic AOS animations on mobile */
  [data-aos='fade-left'],
  [data-aos='fade-right'] {
    transform: none !important;
  }

  /* Ensure grids don't overflow */
  .grid {
    max-width: 100%;
  }
}

/* Tablet specific adjustments */
@media (max-width: 1024px) and (min-width: 769px) {
  nav .container,
  section .container {
    padding-left: 2rem;
    padding-right: 2rem;
  }
}

/* Small mobile devices */
@media (max-width: 640px) {
  /* Even tighter padding on very small screens */
  nav .container,
  section .container {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }

  /* Back to top button */
  #back-to-top {
    bottom: 1rem;
    right: 0.75rem;
  }

  body[dir='rtl'] #back-to-top {
    left: 0.75rem;
    right: auto;
  }

  /* Adjust font sizes for very small screens */
  h1 {
    font-size: 2rem;
  }

  h2 {
    font-size: 1.5rem;
  }
}
