/* ==========================================================================
   SPECIAL METAL (BAHRAIN) - MASTER RESPONSIVE STYLESHEET
   Comprehensive Multi-Device Layouts (Mobile, Tablet, Desktop, Wide)
   ========================================================================== */

/* --------------------------------------------------------------------------
   GLOBAL MOBILE NAVIGATION DRAWER & BACKDROP
   -------------------------------------------------------------------------- */

.nav-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 37, 39, 0.75);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.35s ease, visibility 0.35s ease;
  z-index: 998;
}

.nav-backdrop.active {
  opacity: 1;
  visibility: visible;
}

body.mobile-nav-open {
  overflow: hidden !important;
  touch-action: none;
}

/* --------------------------------------------------------------------------
   BREAKPOINT: 1200px (Medium Desktops & Large Tablets Landscape)
   -------------------------------------------------------------------------- */

@media (max-width: 1200px) {
  .container {
    padding: 0 20px;
  }

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

  .catalog-categories-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
  }

  .country-presence-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
  }

  .applications-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
  }
}

/* --------------------------------------------------------------------------
   BREAKPOINT: 1024px (Tablets & Small Laptops)
   -------------------------------------------------------------------------- */

@media (max-width: 1024px) {
  .hero-title {
    font-size: 2.6rem;
  }

  .nav-menu {
    gap: 16px;
  }

  .nav-link {
    font-size: 0.85rem;
  }

  .vision-grid {
    grid-template-columns: 1fr;
    gap: 36px;
  }

  .vision-stat-card {
    position: static;
    margin-top: -24px;
    margin-left: 16px;
  }

  .products-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
  }

  .why-us-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
  }

  .contact-layout-grid,
  .pillars-grid {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .certs-hero-grid,
  .certs-middle-grid {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .global-map-grid {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .global-metrics-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
  }

  .supply-chain-grid {
    grid-template-columns: 1fr;
    gap: 28px;
  }

  .product-specs-grid {
    grid-template-columns: 1fr;
  }

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

  .alloy-showcase-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
  }

  .processing-gallery-grid {
    grid-template-columns: 1fr 1fr;
    height: auto;
  }

  .gallery-tile.large,
  .gallery-tile {
    height: 220px;
  }

  .footer-grid {
    grid-template-columns: 1fr 1fr;
    gap: 32px;
  }

  .footer-top {
    grid-template-columns: repeat(2, 1fr);
    gap: 32px;
  }

  .spectrum-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .spectrum-arrow {
    transform: rotate(90deg);
    margin: 4px 0;
  }

  .bahrain-origin-banner {
    grid-template-columns: 1fr;
    gap: 24px;
  }
}

/* --------------------------------------------------------------------------
   BREAKPOINT: 900px (Catalog & Detail Specifics)
   -------------------------------------------------------------------------- */

@media (max-width: 900px) {
  .catalog-categories-grid {
    grid-template-columns: 1fr !important;
  }

  .catalog-category-card {
    grid-column: span 1 !important;
  }

  .available-forms-grid {
    grid-template-columns: 1fr !important;
  }

  .form-card-highlight {
    grid-column: span 1 !important;
  }
}

/* --------------------------------------------------------------------------
   BREAKPOINT: 768px (Tablets Portrait & Mobile Large)
   -------------------------------------------------------------------------- */

@media (max-width: 768px) {
  /* Header & Navigation */
  .top-bar-left {
    display: none;
  }

  .top-bar .container {
    justify-content: flex-end;
    padding: 6px 16px;
  }

  .main-header .container {
    height: 64px;
    padding: 0 16px;
  }

  .brand-logo .logo-img {
    height: 42px;
    max-width: 200px;
  }

  .nav-menu {
    position: fixed;
    top: 0;
    right: -100%;
    width: min(320px, 85vw);
    height: 100vh;
    height: 100dvh;
    background-color: #ffffff;
    flex-direction: column;
    align-items: stretch;
    padding: 85px 20px 30px;
    box-shadow: -10px 0 35px rgba(0, 37, 39, 0.3);
    transition: right 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 999;
    gap: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .nav-menu.active {
    right: 0;
  }

  .nav-link {
    font-family: var(--font-condensed);
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-dark);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    width: 100%;
    padding: 14px 12px;
    border-bottom: 1px solid #f1f5f9;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .nav-link:hover,
  .nav-link.active {
    background-color: var(--primary-teal-muted);
    color: var(--primary-teal);
    padding-left: 16px;
  }

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

  .mobile-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    font-size: 1.5rem;
    background: transparent;
    border: none;
    color: var(--primary-teal);
    cursor: pointer;
    z-index: 1002;
  }

  .nav-actions .btn-outline-teal {
    display: none;
  }

  .nav-actions .btn-primary {
    font-size: 0.78rem;
    padding: 8px 12px;
  }

  /* Hero Section */
  .hero-section {
    padding: 50px 0 60px;
    min-height: 420px;
  }

  .hero-content {
    max-width: 100%;
  }

  .hero-title {
    font-size: clamp(2rem, 6.5vw, 2.7rem);
    line-height: 1.15;
    letter-spacing: 0.5px;
  }

  .hero-subtitle {
    font-size: 0.95rem;
    line-height: 1.55;
    margin-bottom: 24px;
  }

  .hero-badges {
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
  }

  .hero-cta {
    flex-direction: column;
    gap: 12px;
    width: 100%;
  }

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

  /* Assurance Bar */
  .assurance-bar {
    padding: 16px 0;
  }

  .assurance-items {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .assurance-item {
    justify-content: center;
    text-align: center;
  }

  .assurance-item::after {
    display: none;
  }

  /* Page Heroes */
  .page-hero {
    padding: 50px 0 40px;
  }

  .page-hero-title {
    font-size: clamp(1.8rem, 6vw, 2.5rem);
  }

  .page-hero-desc {
    font-size: 0.92rem;
  }

  /* Vision & Mission Split */
  .vision-mission-split-container {
    grid-template-columns: 1fr;
  }

  .split-vision-block,
  .split-mission-block {
    padding: 36px 20px;
  }

  /* Metal Switcher Sticky Bar (metal-detail.html) */
  .metal-switcher-bar {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    padding: 10px 12px;
    gap: 8px;
    justify-content: flex-start;
  }

  .metal-switcher-bar::-webkit-scrollbar {
    height: 3px;
  }

  .metal-switcher-bar::-webkit-scrollbar-thumb {
    background-color: var(--primary-teal);
    border-radius: 3px;
  }

  .metal-tab-btn {
    flex-shrink: 0;
    scroll-snap-align: start;
    font-size: 0.8rem;
    padding: 8px 14px;
    white-space: nowrap;
  }

  /* Metal Overview Grid */
  .metal-overview-grid {
    grid-template-columns: 1fr !important;
    gap: 14px;
  }

  .overview-card {
    padding: 20px 16px;
  }

  /* Quality Policy & Assurance */
  .quality-intro-grid {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .quality-policy-stats-banner {
    grid-template-columns: repeat(2, 1fr);
    padding: 24px 18px;
    gap: 20px;
  }

  .workflow-grid {
    grid-template-columns: 1fr 1fr;
    gap: 16px;
  }

  /* Global Presence & Logistics */
  .logistics-map-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
  }

  .logistics-legend-bar {
    gap: 12px;
    font-size: 0.75rem;
  }

  .country-presence-grid {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .origin-stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  .bahrain-origin-banner {
    padding: 28px 20px;
  }

  /* Tables Scroll Container */
  .spec-table-container {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.04);
  }

  .spec-table {
    min-width: 680px;
    width: 100%;
  }

  .spec-table th,
  .spec-table td {
    padding: 10px 12px;
    font-size: 0.8rem;
    white-space: nowrap;
  }

  /* Contact Page Grid */
  .contact-layout-grid {
    grid-template-columns: 1fr;
    gap: 28px;
  }

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

  /* Footer */
  .footer-grid,
  .footer-top {
    grid-template-columns: 1fr;
    gap: 28px;
  }

  .footer-bottom .container {
    flex-direction: column;
    text-align: center;
    gap: 10px;
  }

  /* Modals */
  .modal-card,
  .modal-container {
    width: 95vw;
    max-width: 520px;
    max-height: 90vh;
    max-height: 90dvh;
    padding: 0;
    overflow-y: auto;
  }

  .modal-body {
    padding: 20px 16px;
  }

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

/* --------------------------------------------------------------------------
   BREAKPOINT: 540px & 480px (Standard Mobile Phones)
   -------------------------------------------------------------------------- */

@media (max-width: 540px) {
  .container {
    padding: 0 14px;
  }

  .main-header .container {
    height: 58px;
  }

  .brand-logo .logo-img {
    height: 38px;
    max-width: 170px;
  }

  .nav-actions .btn-primary {
    font-size: 0.72rem;
    padding: 6px 10px;
    letter-spacing: 0.3px;
  }

  .hero-section {
    padding: 40px 0 50px;
  }

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

  .hero-badges .badge-tag {
    font-size: 0.68rem;
    padding: 3px 8px;
  }

  .section-tag {
    font-size: 0.72rem;
    letter-spacing: 0.5px;
  }

  .section-title {
    font-size: 1.55rem;
    line-height: 1.2;
    margin-bottom: 12px;
  }

  .section-desc,
  .section-subheading-clean {
    font-size: 0.88rem;
    line-height: 1.5;
  }

  /* Products & Metal Cards */
  .products-grid,
  .why-us-grid,
  .grades-grid,
  .values-grid,
  .alloy-showcase-grid,
  .workflow-grid,
  .global-metrics-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .catalog-card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .catalog-cat-icon {
    width: 44px;
    height: 44px;
    font-size: 1.4rem;
  }

  .catalog-cat-title {
    font-size: 1.2rem;
  }

  .catalog-item-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .catalog-item-badge {
    align-self: flex-start;
  }

  .catalog-card-footer {
    flex-direction: column;
    gap: 10px;
  }

  .catalog-card-footer .btn {
    width: 100%;
  }

  /* Metal Detail Series Box */
  .metal-series-box {
    padding: 20px 16px;
  }

  .series-box-title {
    font-size: 1.25rem;
  }

  .prop-label {
    font-size: 0.75rem;
  }

  .prop-text {
    font-size: 0.88rem;
  }

  .applications-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .app-card-img-wrap {
    height: 180px;
  }

  .available-forms-grid {
    grid-template-columns: 1fr;
  }

  .forms-subgrid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  /* Quality Policy Stats */
  .quality-policy-stats-banner {
    grid-template-columns: 1fr;
    gap: 16px;
    padding: 20px 14px;
  }

  .q-stat-val {
    font-size: 2.2rem;
  }

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

  /* Logistics Map */
  .logistics-map-title {
    font-size: 0.95rem;
  }

  .origin-stats-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .origin-title {
    font-size: 1.35rem;
  }

  /* Floating WhatsApp Button */
  .whatsapp-float {
    bottom: 20px;
    right: 16px;
    width: 50px;
    height: 50px;
  }

  .whatsapp-popup {
    bottom: 80px;
    right: 16px;
    width: calc(100vw - 32px);
    max-width: 320px;
  }

  /* Toast notification */
  .toast-container {
    left: 14px;
    right: 14px;
    bottom: 14px;
  }

  .toast {
    font-size: 0.82rem;
    padding: 10px 14px;
  }

  /* Input fields: 16px minimum prevents iOS auto-zoom */
  input[type="text"],
  input[type="email"],
  input[type="tel"],
  select,
  textarea {
    font-size: 16px !important;
  }

  .btn-lg {
    padding: 12px 20px;
    font-size: 0.88rem;
  }
}

/* --------------------------------------------------------------------------
   BREAKPOINT: 360px (Smallest Devices e.g. iPhone SE 1st Gen, Galaxy Fold)
   -------------------------------------------------------------------------- */

@media (max-width: 360px) {
  .hero-title {
    font-size: 1.65rem;
  }

  .brand-logo .logo-img {
    height: 32px;
    max-width: 140px;
  }

  .nav-actions .btn-primary {
    display: none;
  }

  .forms-subgrid {
    grid-template-columns: 1fr;
  }

  .country-title-wrap {
    gap: 8px;
  }

  .country-name {
    font-size: 1.15rem;
  }

  .country-flag-icon {
    font-size: 1.6rem;
  }
}

/* --- Mobile Optimizations (Strictly Scoped) --- */
html, body {
  overflow-x: hidden !important;
}

/* Ensure desktop logo is fixed and clean */
.brand-logo .logo-img {
  max-height: 60px;
  width: auto;
}

@media (max-width: 1024px) {
  .mobile-toggle {
    display: flex !important;
  }
}
@media (min-width: 1025px) {
  .mobile-toggle {
    display: none !important;
  }
}

@media (max-width: 768px) {
  /* Scale down typography strictly on mobile */
  .hero-title {
    font-size: clamp(2rem, 8vw, 3.2rem) !important;
    line-height: 1.1;
  }
  .page-hero-title, .cert-hero-title, .metal-hero-title {
    font-size: clamp(1.8rem, 6vw, 2.5rem) !important;
  }
  
  /* Ensure logo fits cleanly on smaller screens */
  .brand-logo .logo-img {
    max-height: 40px !important;
  }

  /* Touch-friendly targets */
  .btn, .nav-link, button, .mobile-toggle {
    min-height: 44px;
    min-width: 44px;
  }
  
  /* Prevent horizontal overflow on mobile containers */
  .container {
    padding-left: 16px !important;
    padding-right: 16px !important;
  }
  
  /* Keep images contained strictly on mobile to avoid breaking desktop layouts */
  img {
    max-width: 100%;
    height: auto;
  }
}

/* Floating Action Button (FAB) */
.mobile-fab {
  position: fixed;
  bottom: 20px;
  left: 20px; /* Moved to left to avoid overlapping AI chat button */
  right: auto;
  width: 56px;
  height: 56px;
  background-color: #25D366;
  color: white;
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(0,0,0,0.3);
  z-index: 1000;
  transition: transform 0.3s ease;
}
.mobile-fab:hover {
  transform: scale(1.1);
}
.mobile-fab svg {
  width: 32px;
  height: 32px;
}
@media (max-width: 768px) {
  .mobile-fab {
    display: flex;
  }
}
