/* ==========================================================================
   MODERN MARINE - COMPREHENSIVE RESPONSIVE ENGINE (2026 Mobile-First System)
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. LARGE DESKTOP (1600px & Above)
   -------------------------------------------------------------------------- */
@media (min-width: 1600px) {
  :root {
    --max-width: 1520px;
  }
}

/* --------------------------------------------------------------------------
   2. DESKTOP / LAPTOP (1280px to 1440px)
   -------------------------------------------------------------------------- */
@media (max-width: 1440px) {
  .hero-title {
    font-size: 3rem;
  }
}

@media (max-width: 1280px) {
  /* .grid-4 removed from max-width query */
  
  .nav-menu {
    gap: 1.1rem;
  }

  .nav-link {
    font-size: 0.875rem;
  }

  .hero-grid {
    grid-template-columns: 1fr 1fr;
    gap: 2.5rem;
  }
}

/* --------------------------------------------------------------------------
   3. SMALL LAPTOP & TABLET LANDSCAPE (992px to 1024px)
   -------------------------------------------------------------------------- */
@media (max-width: 1024px) {
  /* Grid adjustments removed as they are now mobile-first */

  /* Tablet adjustments: Hide desktop links & show Mobile Drawer button */
  .nav-menu {
    display: none !important;
  }

  .hamburger-btn {
    display: flex !important;
  }

  .header-actions {
    gap: 0.5rem;
  }

  .header-action-btn {
    width: 36px;
    height: 36px;
  }
  
  .header-actions .btn-primary {
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
  }

  /* Layout adjustments removed as they are now mobile-first */

  .hero-grid {
    grid-template-columns: 1fr;
    gap: 2.5rem;
  }

  .hero-content {
    text-align: center;
  }

  .hero-description {
    margin-left: auto;
    margin-right: auto;
  }

  .hero-actions {
    justify-content: center;
  }

  .trust-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1.25rem;
  }

  .footer-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 2.5rem;
  }

  .payment-option-grid {
    grid-template-columns: 1fr;
  }
}

/* --------------------------------------------------------------------------
   4. TABLET PORTRAIT (768px to 834px)
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  .utility-bar,
  .top-bar {
    display: none !important;
  }

  .top-bar-features {
    display: none; /* Hide features on mobile/tablet top bar for space */
  }

  .top-bar-inner {
    justify-content: center;
    text-align: center;
  }

  .top-bar-contact {
    justify-content: center;
    gap: 0.75rem;
    font-size: 0.75rem;
  }

  .header-actions .btn-primary {
    display: none !important; /* Hide inline Get a Quote on mobile as it's inside drawer */
  }

  .header-actions a[title="My Account"],
  .header-actions a[title="Search Catalog"] {
    display: none;
  }

  .main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
  }

  .logo-img {
    height: 40px;
    max-width: 180px;
  }

  /* Translucent Hamburger & Cart Buttons on Mobile */
  .header-wrapper.header-transparent:not(.is-sticky) .header-action-btn,
  .header-wrapper.header-transparent:not(.is-sticky) .hamburger-btn {
    background: rgba(255, 255, 255, 0.15) !important;
    backdrop-filter: blur(8px);
    border-color: rgba(255, 255, 255, 0.2);
    color: var(--color-white);
    border-radius: 8px;
  }

  /* Hero Section: Viewport Optimization & Typography */
  .hero {
    padding: 6rem 0 90px 0; /* Bottom padding accounts for mobile bottom nav */
    min-height: 100dvh;
    display: flex;
    align-items: center;
  }
  
  .hero-grid {
    margin-top: 2rem;
  }

  .hero-tag {
    color: #ffffff;
    background: rgba(0, 168, 255, 0.25);
    border: 1px solid rgba(0, 168, 255, 0.5);
    padding: 0.25rem 0.6rem;
    font-size: 0.75rem;
    margin-bottom: 1rem;
  }

  .hero-title {
    font-size: clamp(1.75rem, 5vw, 2.5rem);
    line-height: 1.25;
    margin-bottom: 12px;
  }
  
  .hero-description {
    font-size: 0.95rem;
    line-height: 1.5;
    margin-bottom: 1.5rem;
  }

  .hero-spec-cards {
    grid-template-columns: 1fr;
  }

  .trust-bar {
    padding: 1.25rem;
    margin-top: -2.5rem;
  }

  .trust-grid {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 12px 16px;
  }

  .product-tabs {
    gap: 0.4rem;
  }

  .tab-btn {
    padding: 0.45rem 0.9rem;
    font-size: 0.8rem;
  }

  .footer-grid {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .footer-bottom {
    flex-direction: column;
    text-align: center;
  }

  /* --- Search Section Mobile Refactor --- */
  .search-section .container {
    padding-bottom: 2rem;
  }

  .search-input-group {
    flex-direction: column;
    padding: 0.75rem;
    border-radius: var(--radius-md);
  }

  .search-input-group .search-input {
    width: 100%;
    font-size: 16px; /* Prevent iOS auto-zoom */
  }

  .search-input-group .btn {
    width: 100%;
    margin-top: 0.4rem;
  }

  .popular-tags {
    justify-content: flex-start;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 8px;
    padding-bottom: 0.5rem; /* Space for scrollbar */
  }

  .popular-tags::-webkit-scrollbar {
    display: none;
  }
  
  .popular-tags {
    scrollbar-width: none;
  }

  .tag-btn {
    flex: 0 0 auto;
    border-radius: 20px;
    background: #f0f4f8;
    padding: 6px 14px;
    white-space: nowrap;
  }
  /* --- Category Cards Grid (2 Columns on Mobile) --- */
  .grid:has(.category-card) {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 12px;
  }

  /* --- Category Cards Styles for Mobile --- */
  .category-image-wrap {
    height: 120px !important;
  }
  
  .category-card img,
  .category-image-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: 8px 8px 0 0;
  }

  .category-content {
    padding: 1rem !important;
  }

  .category-title {
    font-size: 1rem !important;
  }

  .category-desc {
    font-size: 0.8rem !important;
    margin-bottom: 0.75rem !important;
  }

  .category-link {
    font-size: 0.8rem !important;
  }

  /* --- Solution Cards Ordering --- */
  .solution-card-layout > div:has(img) {
    order: 1;
  }
  .solution-card-layout > div:not(:has(img)) {
    order: 2;
  }

  /* --- Product Grids (2 Columns on Mobile) --- */
  #home-featured-grid,
  #home-new-arrivals-grid,
  #home-best-sellers-grid,
  #products-grid,
  #pd-related-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    overflow-x: visible;
    padding-bottom: 0;
  }

  #home-featured-grid .product-card,
  #home-new-arrivals-grid .product-card,
  #home-best-sellers-grid .product-card,
  #products-grid .product-card,
  #pd-related-grid .product-card {
    flex: none;
    width: 100%;
    min-width: 0;
  }

  /* --- Product Card Adjustments for 2-Column Mobile --- */
  .product-img-wrap {
    height: 130px !important;
    padding: 0.75rem !important;
  }
  
  .product-info {
    padding: 0.75rem !important;
  }
  
  .product-brand {
    font-size: 0.65rem !important;
    margin-bottom: 0.2rem !important;
  }
  
  .product-title {
    font-size: 0.85rem !important;
    margin-bottom: 0.3rem !important;
    line-height: 1.25 !important;
  }
  
  .product-part-no {
    font-size: 0.7rem !important;
    margin-bottom: 0.4rem !important;
  }
  
  .product-price {
    font-size: 0.95rem !important;
  }
  
  .product-action-btn {
    padding: 0.4rem 0.6rem !important;
    font-size: 0.75rem !important;
  }
  
  .product-badge-wrap {
    top: 0.5rem !important;
    left: 0.5rem !important;
    transform: scale(0.8) !important;
    transform-origin: top left !important;
  }
  
  .product-wishlist-btn {
    top: 0.5rem !important;
    right: 0.5rem !important;
    width: 28px !important;
    height: 28px !important;
  }
  
  .product-wishlist-btn svg {
    width: 14px !important;
    height: 14px !important;
  }

  .product-meta {
    padding-top: 0.5rem !important;
    flex-wrap: wrap !important;
    gap: 0.4rem !important;
  }

  .btn-buy-now {
    font-size: 0.75rem !important;
    padding: 0.4rem 0.25rem !important;
    margin-top: 0.4rem !important;
  }
  
  .btn-buy-now svg {
    width: 14px !important;
    height: 14px !important;
    margin-right: 4px !important;
  }

  /* Make Offer & WhatsApp Button Container */
  .product-info > div[style*="gap: 0.5rem"] {
    gap: 0.25rem !important;
    margin-top: 0.4rem !important;
  }
  
  .product-info > div[style*="gap: 0.5rem"] .product-action-btn {
    font-size: 0.65rem !important;
    padding: 0.35rem 0.2rem !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }
  
  .product-info > div[style*="gap: 0.5rem"] .product-action-btn svg {
    margin-right: 2px !important;
    width: 12px !important;
    height: 12px !important;
    flex-shrink: 0 !important;
  }

  /* --- Floating Widgets & Global Spacing --- */
  .ms-mobile-fab-whatsapp,
  .whatsapp-widget {
    bottom: 16px !important;
    left: 16px !important;
    z-index: 999 !important;
    width: 48px !important;
    height: 48px !important;
  }

  .back-to-top {
    bottom: 16px !important;
    right: 16px !important;
    z-index: 998 !important;
  }
}

@media (max-width: 768px) {
  body {
    padding-bottom: 80px; /* Safe space for bottom nav and floating action buttons */
  }
}

/* --------------------------------------------------------------------------
   5. MOBILE LANDSCAPE & PHABLETS (480px to 576px)
   -------------------------------------------------------------------------- */
@media (max-width: 576px) {
  .cart-table th:nth-child(2),
  .cart-table td:nth-child(2) {
    display: none; /* Hide individual unit price column on mobile cart table */
  }

  /* Make Add to Cart sticky at the bottom on mobile */
  .pd-actions-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    margin-bottom: 1.5rem;
  }
  
  .pd-actions-wrapper .cart-qty-control {
    width: 100%;
    justify-content: center;
    margin-bottom: 0.5rem;
  }

  .pd-add-to-cart {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    z-index: 1050;
    border-radius: 0;
    padding: 1rem;
    font-size: 1.1rem;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.1);
  }

  .pd-rfq {
    width: 100%;
  }

  /* Add padding to body for sticky cart button */
  body.product-page {
    padding-bottom: 70px;
  }
}

/* --------------------------------------------------------------------------
   6. MOBILE SMALL & PHONES (320px to 430px)
   -------------------------------------------------------------------------- */
@media (max-width: 430px) {
  .container {
    padding: 0 1rem;
  }

  .main-header {
    height: 64px;
  }

  .logo-img {
    height: 34px;
    max-width: 130px;
  }

  .header-action-btn,
  .hamburger-btn {
    width: 38px;
    height: 38px;
  }

  .header-actions {
    gap: 0.35rem;
  }

  .hero-title {
    font-size: 1.75rem;
  }

  .hero-description {
    font-size: 0.95rem;
    margin-bottom: 1.5rem;
  }

  .hero-actions {
    flex-direction: row;
    flex-wrap: wrap;
    width: 100%;
    gap: 0.75rem;
  }

  .hero-actions .btn {
    width: auto;
    padding: 0.75rem 1.25rem;
    font-size: 0.9rem;
  }

  .trust-bar {
    margin-top: -2rem;
  }

  .product-img-wrap {
    height: 170px;
  }

  .product-info {
    padding: 1rem;
  }

  .product-price {
    font-size: 1.05rem;
  }

  .product-action-btn {
    padding: 0.4rem 0.65rem;
    font-size: 0.775rem;
  }

  .mobile-nav-drawer {
    width: 280px;
  }

  .form-card {
    padding: 1.25rem;
  }

  .cart-summary-card {
    padding: 1.25rem;
  }

  /* --- Product Gallery Compact Padding --- */
  #pd-gallery-wrap {
    padding: 1.25rem !important;
  }
  #pd-main-img {
    max-height: 240px !important;
  }

  .toast-container {
    right: 0.75rem;
    left: 0.75rem;
    bottom: 1rem;
  }
}

@media (max-width: 360px) {
  .logo-img {
    height: 34px;
    max-width: 150px;
  }

  .hero-title {
    font-size: 1.55rem;
  }
}
/* --------------------------------------------------------------------------
   7. RESPONSIVE CART TABLE (Card Layout on Mobile)
   -------------------------------------------------------------------------- */
@media (max-width: 576px) {
  .cart-table-wrapper {
    overflow-x: visible;
  }

  .cart-table {
    min-width: 0;
    width: 100%;
  }

  .cart-table, .cart-table tbody, .cart-table tr, .cart-table td {
    display: block;
    width: 100%;
  }

  .cart-table thead {
    display: none;
  }

  .cart-table tr {
    margin-bottom: 1.5rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-off-white);
    padding: 1rem;
    position: relative;
  }

  .cart-table td {
    border: none;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    position: relative;
    padding: 0.75rem 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-align: right;
  }

  .cart-table td:last-child {
    border-bottom: none;
    padding-bottom: 0;
    justify-content: center;
    margin-top: 0.5rem;
  }

  .cart-table td::before {
    content: attr(data-label);
    position: absolute;
    left: 0;
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--color-navy-light);
  }

  .cart-item-flex {
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
    padding-left: 80px;
    width: 100%;
  }

  .cart-item-img {
    position: absolute;
    left: 0;
    top: 0.5rem;
  }
}

/* --------------------------------------------------------------------------
   8. PROFESSIONAL MOBILE POLISH & TOUCH ENHANCEMENTS
   -------------------------------------------------------------------------- */
@media (max-width: 1024px) {
  /* Improve touch targets for links and buttons */
  .nav-link, .mobile-drawer-link, .utility-link, .footer-link {
    min-height: 44px;
    display: flex;
    align-items: center;
  }

  .btn {
    min-height: 44px;
  }

  /* Enhance inputs for mobile */
  input, select, textarea {
    font-size: 16px !important; /* Prevents iOS auto-zoom */
    padding: 0.85rem 1rem; /* Larger touch area */
  }

  select, select.form-control {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    width: 100%;
  }

  /* Add glassmorphism to bottom nav for a premium feel */
  .ms-mobile-bottom-nav {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-top: 1px solid rgba(22, 82, 160, 0.1);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.05);
    padding-bottom: env(safe-area-inset-bottom, 0px); /* iPhone notch support */
  }

  .ms-bottom-nav-item {
    min-height: 56px;
  }

  /* Relax section padding handled in style.css */

  /* Prevent oversized images from breaking layout */
  img, video {
    max-width: 100%;
    height: auto;
  }
}
