/* =====================================================
   CAEC MAQUINADOS INDUSTRIALES — Responsive Design
   Mobile-first desde 320px hasta 1400px+
   ===================================================== */

/* ══════════════════════════════════════════
   DESKTOP GRANDE (1400px+)
══════════════════════════════════════════ */
@media (min-width: 1400px) {
  :root { --container-max: 1320px; }
}

/* ══════════════════════════════════════════
   TABLET GRANDE / LAPTOP (992px - 1199px)
══════════════════════════════════════════ */
@media (max-width: 1199px) {
  .values-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-5);
  }

  .servicios-layout {
    gap: var(--space-8);
  }

  .footer-grid {
    grid-template-columns: 1fr 1fr;
    gap: var(--space-8);
  }

  .footer-brand {
    grid-column: 1 / -1;
  }
}

/* ══════════════════════════════════════════
   TABLET (768px - 991px)
══════════════════════════════════════════ */
@media (max-width: 991px) {
  /* Navbar */
  .nav-links { display: none; }
  .nav-burger { display: flex; }

  /* Hero */
  .hero-title {
    font-size: clamp(2.5rem, 8vw, 4rem);
  }

  .carousel-prev,
  .carousel-next {
    width: 42px;
    height: 42px;
    font-size: var(--text-base);
  }

  /* Nosotros */
  .values-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Servicios */
  .servicios-layout {
    grid-template-columns: 1fr;
    gap: var(--space-10);
  }

  .servicios-content .section-header {
    text-align: center;
  }

  /* Stats */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .stat-card::after {
    display: none;
  }

  .stat-card {
    border-bottom: 1px solid var(--glass-border);
    border-right: 1px solid var(--glass-border);
  }

  .stat-card:nth-child(2n)::after,
  .stat-card:nth-child(2n) {
    border-right: none;
  }

  /* Gallery */
  .gallery-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-4);
  }

  /* Contact */
  .contact-grid {
    flex-direction: column;
    gap: var(--space-8);
  }

  /* Footer */
  .footer-grid {
    grid-template-columns: 1fr 1fr;
    gap: var(--space-8);
  }

  .footer-brand {
    grid-column: 1 / -1;
  }
}

/* ══════════════════════════════════════════
   MÓVIL GRANDE (576px - 767px)
══════════════════════════════════════════ */
@media (max-width: 767px) {
  /* Base */
  :root {
    --navbar-height: var(--navbar-height-mobile);
    --section-padding: var(--section-padding-sm);
  }

  /* Preloader */
  .preloader-logo { font-size: var(--text-3xl); }

  /* Navbar */
  #navbar {
    padding: 0 var(--space-4);
  }

  .nav-logo-text .brand-sub {
    display: none;
  }

  /* Hero */
  .hero-title {
    font-size: clamp(2rem, 10vw, 3rem);
  }

  .hero-subtitle { font-size: var(--text-base); }

  .hero-description { display: none; }

  .hero-actions {
    flex-direction: column;
    align-items: center;
    gap: var(--space-3);
  }

  .hero-actions .btn {
    width: 100%;
    min-width: 0;
    max-width: 280px;
    justify-content: center;
    padding: 12px 16px;
    white-space: normal;
  }

  .carousel-prev,
  .carousel-next {
    display: none;
  }

  .hero-scroll { display: none; }

  /* Section headers */
  .section-title {
    font-size: var(--text-3xl);
  }

  /* Nosotros */
  #nosotros {
    padding: 40px 0;
  }

  .values-grid {
    grid-template-columns: 1fr;
    gap: var(--space-4);
  }

  /* Stats */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .stat-number {
    font-size: var(--text-3xl);
  }
  
  .stat-card { padding: var(--space-4) var(--space-3); }

  /* Gallery */
  .gallery-grid {
    grid-template-columns: 1fr;
  }

  .gallery-filters {
    gap: var(--space-1);
    flex-wrap: wrap;
    justify-content: center;
  }

  .filter-btn {
    font-size: 0.7rem;
    padding: var(--space-2) var(--space-3);
  }

  /* TikTok embeds */
  .tiktok-item {
    height: auto !important;
  }
  .tiktok-embed {
    max-height: auto !important;
  }
  
  .tiktok-iframe {
    height: auto;
    max-height: none;
    aspect-ratio: 9/16;
  }

  /* Lightbox */
  .lightbox-prev,
  .lightbox-next {
    width: 40px;
    height: 40px;
    font-size: var(--text-base);
  }

  .lightbox-prev { left: var(--space-2); }
  .lightbox-next { right: var(--space-2); }

  .lightbox-iframe {
    width: 95vw;
    height: 53vw;
  }

  /* Contact */
  .contact-grid { grid-template-columns: 1fr; gap: var(--space-6); }
  .map-wrapper { height: 260px; }

  /* Chat Container & Panel */
  .chat-bubble {
    bottom: 16px !important;
    right: 16px !important;
  }

  /* El botón real del chat dentro de la burbuja */
  .chat-toggle {
    width: 44px !important;
    height: 44px !important;
    font-size: 1.2rem !important;
  }

  .chat-panel {
    width: calc(100vw - 32px);
    right: 16px;
    bottom: 74px;
    max-height: 450px;
    border-radius: var(--radius-lg);
  }

  /* Vertical Floating Buttons Layout for Mobile */
  .whatsapp-float {
    bottom: 70px !important; /* 16 + 44 + 10 */
    right: 16px !important;
    width: 44px !important;
    height: 44px !important;
  }
  
  .tiktok-float {
    bottom: 124px !important; /* 70 + 44 + 10 */
    right: 16px !important; 
    width: 44px !important;
    height: 44px !important;
  }

  #scrollTop {
    bottom: 16px !important;
    left: 16px !important;
    right: auto !important;
    width: 40px !important;
    height: 40px !important;
    padding: 0 !important;
  }

  /* Footer */
  .footer-grid {
    grid-template-columns: 1fr;
    gap: var(--space-6);
  }

  .footer-bottom {
    flex-direction: column;
    text-align: center;
  }

  /* Scroll top */
  #scrollTop {
    bottom: var(--space-4);
    left: var(--space-4);
    width: 38px;
    height: 38px;
  }
}

/* ══════════════════════════════════════════
   MÓVIL PEQUEÑO (max 575px)
══════════════════════════════════════════ */
@media (max-width: 575px) {
  /* Hero */
  #hero { min-height: auto; padding: 100px 0 60px 0; }

  .hero-content { padding: 0 var(--space-3); }

  .hero-eyebrow { font-size: 0.65rem; }
  .hero-eyebrow::before,
  .hero-eyebrow::after { width: 16px; }

  /* Sections */
  .section-badge { font-size: 0.65rem; padding: var(--space-1) var(--space-3); }
  
  /* Utilities */
  .section-divider { margin-bottom: var(--space-4); }

  /* Stats */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .stat-card { padding: var(--space-4) var(--space-2); }

  /* Value cards */
  .value-card { padding: var(--space-5); }

  /* Services Video */
  .video-wrapper { border-radius: var(--radius-md); }

  /* Tabs */
  .services-tabs { gap: 0; }
  .tab-btn {
    padding: var(--space-3) var(--space-4);
    font-size: 0.7rem;
  }

  /* Gallery */
  .gallery-item { aspect-ratio: 16/9; }

  /* Contact form */
  .contact-form { padding: var(--space-5); }
  .contact-info-card { padding: var(--space-5); }

  /* PDF download */
  .pdf-download {
    width: 100%;
    justify-content: center;
  }

  /* Chat */
  .chat-panel { max-height: 440px; }

  .chat-messages { min-height: 200px; max-height: 260px; }

  /* Footer */
  .footer-social { justify-content: center; }
  .footer-brand p { max-width: 100%; }
}

/* ══════════════════════════════════════════
   EXTRA SMALL (max 360px)
══════════════════════════════════════════ */
@media (max-width: 360px) {
  .hero-title { 
    font-size: 1.75rem;
    line-height: 1.1;
  }

  .btn {
    padding: 12px 24px;
    font-size: 0.75rem;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .stat-card::after { display: none; }
}

/* ══════════════════════════════════════════
  ACCESIBILIDAD - Reduce 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;
  }

  .hero-slide {
    transition: opacity 0.3s ease !important;
    transform: none !important;
  }

  .reveal,
  .reveal-left,
  .reveal-right,
  .reveal-scale {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }
}

/* ══════════════════════════════════════════
  PRINT
══════════════════════════════════════════ */
@media print {
  #navbar,
  .chat-bubble,
  #preloader,
  #scrollTop,
  .hero-canvas,
  .carousel-controls,
  .carousel-prev,
  .carousel-next {
    display: none !important;
  }

  body {
    background: white;
    color: black;
  }

  section { padding: 20px 0; }
}
