/* =========================================
   CSS Custom Properties (Brand Palette)
   Sincronizadas con tailwind.config
   ========================================= */
:root {
  --color-primary: #16a34a;
  --color-primary-dark: #15803d;
  --color-accent: #facc15;
  --color-accent-dark: #eab308;
  --color-text: #1f2937;
  --color-text-light: #6b7280;
  --color-bg: #ffffff;
  --color-bg-alt: #f9fafb;
  --color-border: #e5e7eb;
  --color-danger: #dc2626;
  --color-success: #16a34a;
  --color-whatsapp: #25d366;
  --header-height: 80px;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
}

/* =========================================
   Global & Base Styles
   ========================================= */
html {
  scroll-behavior: smooth;
  scroll-padding-top: var(--header-height);
}

/* Fallback: cada sección deja espacio al hacer scroll */
section[id] {
  scroll-margin-top: var(--header-height);
}

/* Mejor renderizado de fuentes */
body {
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Imágenes siempre responsivas por defecto */
img {
  max-width: 100%;
  height: auto;
}

/* =========================================
   Keyframe Animations
   ========================================= */
@keyframes pulse-whatsapp {
  0% {
    box-shadow: 0 0 0 0 rgba(37, 211, 102, 0.7);
  }
  70% {
    box-shadow: 0 0 0 15px rgba(37, 211, 102, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(37, 211, 102, 0);
  }
}

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

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* =========================================
   Sticky Header
   ========================================= */
.site-header {
  transition: background-color 0.3s ease, box-shadow 0.3s ease;
  background-color: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.site-header.scrolled {
  background-color: rgba(255, 255, 255, 0.98);
  box-shadow: var(--shadow-md);
}

/* =========================================
   Floating WhatsApp Button
   ========================================= */
.whatsapp-float {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  background-color: var(--color-whatsapp);
  color: #ffffff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 100;
  animation: pulse-whatsapp 2.5s infinite;
  transition: transform 0.2s ease, background-color 0.2s ease;
  text-decoration: none;
  will-change: transform;
}

.whatsapp-float:hover {
  transform: scale(1.1);
  background-color: #1eb954;
}

.whatsapp-float:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 3px;
}

/* =========================================
   Back to Top Button
   ========================================= */
#back-to-top {
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 48px;
  height: 48px;
  background-color: #1f2937;
  color: #ffffff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
  z-index: 99;
  border: none;
  cursor: pointer;
  transition: opacity 0.3s ease, transform 0.3s ease, background-color 0.3s ease;
}

#back-to-top:hover {
  background-color: var(--color-primary);
  transform: translateY(-3px) scale(1.05);
}

#back-to-top:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 3px;
}

/* =========================================
   Mobile Menu & Backdrop
   Nota: main.js usa la clase .open
   ========================================= */
.mobile-menu-backdrop {
  transition: opacity 0.3s ease;
}

.mobile-menu-backdrop.open {
  display: block;
  opacity: 1;
}

.mobile-menu {
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
}

.mobile-menu.open {
  transform: translateX(0) !important;
}

/* =========================================
   Navigation Links (subrayado animado)
   ========================================= */
.nav-link {
  position: relative;
  padding-bottom: 2px;
}

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

.nav-link:hover::after,
.nav-link.active::after {
  width: 100%;
}

/* =========================================
   Service Cards
   ========================================= */
.service-card {
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  will-change: transform;
}

.service-card:hover {
  transform: translateY(-8px);
  box-shadow: var(--shadow-xl);
}

/* =========================================
   Testimonials & Star Ratings
   ========================================= */
.star-rating {
  color: var(--color-accent);
  font-size: 1.25rem;
  letter-spacing: 0.1em;
  line-height: 1;
}

/* =========================================
   Gallery
   ========================================= */
#galeria-grid a {
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

#galeria-grid a:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-xl);
}

#galeria-grid img {
  transition: transform 0.5s ease;
}

/* =========================================
   Form Inputs (Accessible Focus States)
   ========================================= */
.form-input,
#contacto-form input,
#contacto-form textarea,
#contacto-form select {
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#contacto-form input:focus,
#contacto-form textarea:focus,
#contacto-form select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 4px rgba(22, 163, 74, 0.15);
}

#contacto-form input.border-red-500:focus,
#contacto-form textarea.border-red-500:focus,
#contacto-form select.border-red-500:focus {
  border-color: var(--color-danger);
  box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.15);
}

/* Botón de submit con feedback */
#contacto-form button[type="submit"] {
  transition: background-color 0.2s ease, transform 0.1s ease;
}

#contacto-form button[type="submit"]:hover:not(:disabled) {
  background-color: var(--color-primary-dark);
}

#contacto-form button[type="submit"]:active:not(:disabled) {
  transform: scale(0.98);
}

#contacto-form button[type="submit"]:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

/* =========================================
   Scroll Animations (Fade In Up)
   ========================================= */
.scroll-animate {
  opacity: 0;
}

.scroll-animate.animated {
  animation: fadeInUp 0.8s ease forwards;
}

/* Aplica fadeInUp a las tarjetas dinámicas */
.service-card,
#testimonios-grid > div,
#certificados-grid > div,
#galeria-grid > a {
  animation: fadeInUp 0.5s ease both;
}

/* =========================================
   Media Queries (Mobile First)
   ========================================= */

/* Small devices (640px and up) */
@media (min-width: 640px) {
  .whatsapp-float {
    width: 64px;
    height: 64px;
    font-size: 36px;
  }

  #back-to-top {
    width: 52px;
    height: 52px;
    bottom: 100px;
  }
}

/* Medium devices (768px and up) */
@media (min-width: 768px) {
  .mobile-menu {
    max-width: 400px;
  }
}

/* Large devices (1024px and up) */
@media (min-width: 1024px) {
  .mobile-menu,
  .mobile-menu-backdrop {
    display: none !important;
  }
}

/* Small screens: ajusta los botones flotantes para que no se choquen */
@media (max-width: 640px) {
  .whatsapp-float {
    bottom: 20px;
    right: 20px;
    width: 56px;
    height: 56px;
    font-size: 30px;
  }

  #back-to-top {
    bottom: 88px;
    right: 20px;
    width: 44px;
    height: 44px;
  }
}

/* =========================================
   Accessibility: Focus visible global
   ========================================= */
:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 3px;
}

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

  .scroll-animate {
    opacity: 1;
    transform: none;
  }

  .whatsapp-float {
    animation: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  }

  .service-card:hover,
  #galeria-grid a:hover {
    transform: none;
  }
}

/* =========================================
   Print Styles
   ========================================= */
@media print {
  .site-header,
  .whatsapp-float,
  #back-to-top,
  .mobile-menu,
  .mobile-menu-backdrop,
  footer {
    display: none !important;
  }

  body {
    color: #000;
    background: #fff;
  }

  section {
    page-break-inside: avoid;
  }
}