/* ==========================================================================
   ACUEDUCTOS PERÚ - RESPONSIVE STYLESHEET
   Breakpoints, Mobile Drawer Navigation, Touch Optimizations
   ========================================================================== */

/* --------------------------------------------------------------------------
   Desktop & Large Screens (max-width: 1200px)
   -------------------------------------------------------------------------- */
@media (max-width: 1200px) {
  .hero-grid {
    grid-template-columns: 1fr;
    gap: 3rem;
  }

  .hero-media {
    max-width: 600px;
    margin: 0 auto;
  }

  .footer-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 2.5rem;
  }

  .contact-grid {
    grid-template-columns: 1fr;
    gap: 2.5rem;
  }
}

/* --------------------------------------------------------------------------
   Medium Screens / Tablets (max-width: 992px)
   -------------------------------------------------------------------------- */
@media (max-width: 992px) {
  .top-bar {
    display: none; /* Hide top bar on tablets/mobile to maximize screen space */
  }

  /* Header mobile fixes: eliminate containing block & ensure proper z-index layer */
  .site-header {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    background-color: #ffffff !important;
    z-index: 1100 !important;
  }

  .mobile-toggle {
    display: block;
    background: none;
    border: none;
    font-size: 1.6rem;
    color: var(--primary);
    cursor: pointer;
    padding: 0.5rem;
    z-index: 1105;
  }

  .header-actions .btn-whatsapp {
    display: none; /* In header, reserve for mobile menu or floating button */
  }

  /* Mobile Slide-in Drawer */
  .nav-menu {
    position: fixed !important;
    top: 0 !important;
    right: -100% !important;
    width: 290px !important;
    max-width: 82vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    background-color: #0a2540 !important;
    flex-direction: column !important;
    align-items: stretch !important;
    padding: 5rem 1.5rem 2rem !important;
    gap: 0.35rem !important;
    box-shadow: -8px 0 30px rgba(0, 0, 0, 0.6) !important;
    transition: right 0.32s cubic-bezier(0.16, 1, 0.3, 1) !important;
    z-index: 1120 !important;
    overflow-y: auto !important;
    pointer-events: auto !important;
  }

  .nav-menu.open {
    right: 0 !important;
  }

  .nav-link {
    color: #ffffff !important;
    font-size: 1.05rem !important;
    font-weight: 500 !important;
    width: 100% !important;
    padding: 0.85rem 0.9rem !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
    display: block !important;
    cursor: pointer !important;
    pointer-events: auto !important;
    transition: all 0.2s ease !important;
    border-radius: var(--radius-sm) !important;
    text-align: left !important;
  }

  .nav-link::after {
    display: none !important;
  }

  .nav-link:hover,
  .nav-link.active {
    color: #00b4d8 !important;
    background-color: rgba(0, 180, 216, 0.14) !important;
  }

  /* Close X button inside drawer */
  .mobile-menu-close {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    position: absolute !important;
    top: 1.25rem !important;
    right: 1.25rem !important;
    width: 38px !important;
    height: 38px !important;
    background: rgba(255, 255, 255, 0.12) !important;
    border-radius: 50% !important;
    border: none !important;
    color: #ffffff !important;
    font-size: 1.2rem !important;
    cursor: pointer !important;
    transition: background 0.2s ease !important;
    z-index: 1130 !important;
  }

  .mobile-menu-close:hover {
    background: rgba(255, 255, 255, 0.25) !important;
  }

  /* Backdrop Overlay on Body */
  .mobile-drawer-backdrop {
    position: fixed !important;
    inset: 0 !important;
    background: rgba(0, 0, 0, 0.55) !important;
    backdrop-filter: blur(3px) !important;
    -webkit-backdrop-filter: blur(3px) !important;
    z-index: 1040 !important;
    opacity: 0 !important;
    visibility: hidden !important;
    transition: opacity 0.3s ease, visibility 0.3s ease !important;
    pointer-events: none !important;
  }

  .mobile-drawer-backdrop.open {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
  }

  .grid-5 {
    grid-template-columns: repeat(2, 1fr);
  }

  .grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }

  .grid-3 {
    grid-template-columns: repeat(2, 1fr);
  }

  .service-block-inner {
    grid-template-columns: 1fr;
  }

  .service-block-inner.reverse {
    direction: ltr;
  }

  .service-image {
    min-height: 280px;
    max-height: 360px;
  }

  .service-body {
    padding: 2rem 1.5rem;
  }

  .hero-metrics {
    grid-template-columns: repeat(2, 1fr);
    gap: 1.25rem;
  }
}

/* --------------------------------------------------------------------------
   Small Screens / Mobile Phones (max-width: 768px)
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  .section {
    padding: 3.5rem 0;
  }

  .section-header {
    margin-bottom: 2.5rem;
  }

  .grid-5,
  .grid-4,
  .grid-3,
  .grid-2 {
    grid-template-columns: 1fr;
  }

  .form-row {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .modal-product-grid {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }

  .contact-form-card,
  .contact-info-card {
    padding: 2rem 1.5rem;
  }

  .catalog-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .search-input-wrapper {
    min-width: 100%;
  }

  .filter-tabs {
    overflow-x: auto;
    padding-bottom: 0.5rem;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
  }

  .filter-tabs .tab-btn {
    white-space: nowrap;
  }

  .footer-grid {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

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

  .footer-bottom-links {
    justify-content: center;
  }

  .floating-whatsapp {
    bottom: 1.25rem;
    right: 1.25rem;
    width: 52px;
    height: 52px;
    font-size: 1.75rem;
  }

  .whatsapp-tooltip {
    display: none; /* Hide tooltip on touch screens */
  }

  .hero {
    padding: 4.5rem 0 3.5rem;
  }

  .hero-title {
    font-size: 2.1rem;
  }

  .hero-cta {
    flex-direction: column;
  }

  .hero-cta .btn {
    width: 100%;
  }

  .viewer-3d-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .viewer-mode-tabs {
    width: 100%;
    justify-content: center;
  }

  .viewer-steps-bar {
    padding: 0.5rem 1rem;
  }

  .viewer-3d-canvas-wrapper {
    min-height: 360px;
  }

  #threeCanvasContainer {
    height: 380px;
  }
}

/* --------------------------------------------------------------------------
   Extra Small Screens (max-width: 480px)
   -------------------------------------------------------------------------- */
@media (max-width: 480px) {
  .hero-metrics {
    grid-template-columns: 1fr;
  }

  .metric-item {
    text-align: center;
  }

  .product-actions {
    flex-direction: column;
  }
}
