/* ================================================================
   ZORPIDO RESPONSIVE UTILITIES
   Global responsive overrides — loaded AFTER style.css
   Adds missing breakpoints, fluid typography, large-screen
   support, foldable/landscape handling, and accessibility fixes.
   ================================================================ */

/* ── Responsive CSS Custom Properties ─────────────────────── */
:root {
  --resp-space-xs: clamp(0.5rem, 1.5vw, 0.75rem);
  --resp-space-sm: clamp(0.75rem, 2vw, 1rem);
  --resp-space-md: clamp(1rem, 3vw, 1.5rem);
  --resp-space-lg: clamp(1.5rem, 4vw, 2.5rem);
  --resp-space-xl: clamp(2rem, 5vw, 4rem);
  --resp-font-xs: clamp(0.7rem, 1.2vw, 0.8rem);
  --resp-font-sm: clamp(0.8rem, 1.5vw, 0.95rem);
  --resp-font-base: clamp(0.875rem, 1.6vw, 1rem);
  --resp-font-md: clamp(1rem, 2vw, 1.25rem);
  --resp-font-lg: clamp(1.25rem, 2.5vw, 1.75rem);
  --resp-font-xl: clamp(1.5rem, 3.5vw, 2.5rem);
  --resp-font-xxl: clamp(2rem, 5vw, 3.5rem);
}

/* ── Safe Area Inset Support (Notched Phones) ─────────────── */
body {
  padding-left: env(safe-area-inset-left, 0);
  padding-right: env(safe-area-inset-right, 0);
}

@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .footer,
  footer {
    padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0));
  }
}

/* ── Global Overflow Prevention ───────────────────────────── */
main,
section,
article,
.container,
.container-fluid {
  overflow-wrap: break-word;
  word-wrap: break-word;
}

/* Prevent absolutely-positioned decorations from causing overflow */
section {
  overflow-x: clip;
}

/* ── Responsive Images & Media (Safety Net) ───────────────── */
img,
video,
picture,
canvas,
svg {
  max-width: 100%;
  height: auto;
}

iframe {
  max-width: 100%;
  border: 0;
}

/* ── Responsive Tables (Global Wrapper) ───────────────────── */
.table-responsive-auto {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.table-responsive-auto > table {
  min-width: 600px;
}

/* Auto-wrap any table that isn't already in a responsive wrapper */
@media (max-width: 768px) {
  table:not(.table-responsive-auto table):not(.no-responsive) {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* ── Fix nested/double .table-responsive wrappers ──────────── */
/* If a `.table-responsive` is inside another `.table-responsive`,
   collapse the inner one so we don't get double scrollbars.     */
.table-responsive .table-responsive {
  overflow: visible;
  -webkit-overflow-scrolling: auto;
  scrollbar-width: auto;
}

.table-responsive .table-responsive > table {
  min-width: 0;
}

/* Normalize .table-responsive so it never exceeds the viewport */
.table-responsive {
  max-width: 100%;
}

/* ── Modal responsive rules ────────────────────────────────── */
.modal-dialog {
  margin: 1.25rem auto;
  width: auto;
  max-width: calc(100vw - 2rem);
}

.modal-dialog-scrollable .modal-body {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 575.98px) {
  .modal-dialog {
    margin: 1.25rem 1rem;
    max-width: calc(100vw - 2rem);
  }

  .modal-footer {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }

  .modal-footer > .btn {
    width: 100%;
    margin: 0 !important;
  }

  .modal-footer > .btn + .btn {
    margin-top: 0.25rem;
  }
}

/* ── Form controls never overflow ──────────────────────────── */
input,
select,
textarea,
.form-control,
.form-select {
  max-width: 100%;
}

/* ── Global grid/flex child overflow prevention ────────────── */
.row > [class*="col-"],
.d-flex > * {
  min-width: 0;
}

/* ── Fluid Typography Overrides ───────────────────────────── */
h1, .h1 {
  font-size: clamp(1.75rem, 4.5vw, 3rem);
}

h2, .h2 {
  font-size: clamp(1.5rem, 3.5vw, 2.5rem);
}

h3, .h3 {
  font-size: clamp(1.25rem, 3vw, 2rem);
}

h4, .h4 {
  font-size: clamp(1.1rem, 2.5vw, 1.5rem);
}

h5, .h5 {
  font-size: clamp(1rem, 2vw, 1.25rem);
}

h6, .h6 {
  font-size: clamp(0.875rem, 1.8vw, 1rem);
}

/* ── Form Responsive Defaults ─────────────────────────────── */
input,
select,
textarea,
.form-control,
.form-select {
  max-width: 100%;
  font-size: max(16px, 1rem); /* Prevents iOS zoom on focus */
}

/* ── Touch Target Enforcement ─────────────────────────────── */
@media (pointer: coarse) {
  button,
  .btn,
  select.form-select,
  input.form-control,
  .nav-link,
  .dropdown-item,
  a[role="button"],
  [type="submit"],
  [type="button"] {
    min-height: 44px;
    min-width: 44px;
  }
}

/* ── Focus Visibility ─────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--nb-red, #D92B2B);
  outline-offset: 2px;
}

/* ================================================================
   BREAKPOINT: 320px — Tiny Phones (iPhone SE, Galaxy A)
   ================================================================ */
@media (max-width: 359px) {
  body {
    font-size: 13px;
  }

  .container {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  /* Prevent modal overflow on tiny screens */
  .modal-dialog {
    margin: 0.5rem;
  }

  .modal-body {
    padding: 1rem;
  }

  /* Compact footer */
  .footer-container {
    padding: 15px 8px !important;
    border-radius: 12px !important;
  }

  .footer-container .row {
    padding: 8px !important;
  }

  .footer-container h5 {
    font-size: 1rem;
  }

  /* CTA Section */
  .cta-section {
    max-width: 100% !important;
    border-radius: 1rem !important;
    padding: 2rem 1rem !important;
  }

  .cta-title {
    font-size: 1.5rem !important;
  }

  /* Cards */
  .stats-card,
  .reward-card,
  .glass-card {
    padding: 1rem;
  }

  /* Gallery */
  .gallery-grid {
    grid-template-columns: 1fr !important;
    gap: 1rem;
  }

  /* Testimonials */
  .testimonial-card {
    padding: 20px 14px !important;
    min-height: auto !important;
  }

  .testimonial-message p {
    font-size: 14px !important;
  }

  .quote-icon {
    font-size: 36px !important;
  }

  /* Services */
  .zorpido-services .container {
    padding: 0 12px;
  }

  .zorpido-services .service-card {
    padding: 20px 16px;
  }
}

/* ================================================================
   BREAKPOINT: 360px — Small Phones (Common Android)
   ================================================================ */
@media (max-width: 389px) {
  .z-hero-headline {
    font-size: 42px !important;
  }

  .z-hero-tagline {
    font-size: 14px;
  }

  .z-cta-row .z-btn-primary,
  .z-cta-row .z-btn-outline {
    padding: 12px 20px;
    font-size: 13px;
  }

  .z-proof-strip {
    flex-direction: column;
    align-items: center;
    gap: 10px;
  }

  .z-proof-stat {
    text-align: center;
  }
}

/* ================================================================
   BREAKPOINT: 390px–480px — Standard Phones
   ================================================================ */
@media (max-width: 480px) {
  /* General spacing */
  .container {
    padding-left: 14px !important;
    padding-right: 14px !important;
  }

  /* Footer company info */
  .company-info .col-md-3 {
    padding: 0.5rem;
  }

  .company-info h6 {
    font-size: 0.85rem;
  }

  /* Modals */
  .modal-dialog {
    margin: 0.75rem;
    max-width: calc(100vw - 1.5rem);
  }

  /* Card adjustments */
  .card-body {
    padding: 1rem;
  }

  /* Button groups */
  .btn-group,
  .d-flex.gap-2,
  .d-flex.gap-3 {
    flex-wrap: wrap;
  }

  /* Service cards */
  .zorpido-services .services-grid {
    grid-template-columns: 1fr !important;
  }

  /* Stat numbers */
  .stat-number {
    font-size: 1.75rem;
  }

  /* Gallery */
  .gallery-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.75rem;
  }

  .gallery-card {
    aspect-ratio: 1;
  }

  /* CTA */
  .cta-buttons {
    flex-direction: column;
    align-items: stretch;
  }

  .btn-primary-cta,
  .btn-secondary-cta {
    width: 100%;
    justify-content: center;
  }

  /* Loyalty */
  .loyalty-lead {
    font-size: 1.1rem !important;
    flex-wrap: wrap;
  }

  .benefits-list li {
    padding: 0.75rem;
    font-size: 0.9rem;
    gap: 0.75rem;
  }

  /* Badges / chips */
  .z-open-badge,
  .z-delivery-badge {
    font-size: 11px;
    padding: 5px 12px;
  }

  /* Featured slider */
  .zorpido-carousel {
    padding: 0.75rem;
    border-radius: 16px;
  }

  .control-arrow {
    width: 36px;
    height: 36px;
    font-size: 1rem;
  }

  .thumbnail-item {
    width: 60px;
    height: 45px;
  }

  /* Toast notifications */
  .notification-toast,
  .zorpido-toast-container {
    left: 10px !important;
    right: 10px !important;
    max-width: none !important;
    min-width: auto !important;
  }
}

/* ================================================================
   BREAKPOINT: 481px–576px — Large Phones / Phablets
   ================================================================ */
@media (min-width: 481px) and (max-width: 576px) {
  .gallery-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .pos-container {
    padding: 16px !important;
  }
}

/* ================================================================
   BREAKPOINT: 577px–768px — Small Tablets (iPad Mini, etc.)
   ================================================================ */
@media (min-width: 577px) and (max-width: 768px) {
  .gallery-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1.25rem;
  }

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

/* ================================================================
   BREAKPOINT: 769px–1024px — Tablets (iPad, iPad Air)
   ================================================================ */
@media (min-width: 769px) and (max-width: 1024px) {
  .gallery-grid {
    grid-template-columns: repeat(3, 1fr);
  }

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

  /* Footer grid */
  .footer-container .row > [class*="col-lg"] {
    flex: 0 0 50%;
    max-width: 50%;
  }
}

/* ================================================================
   BREAKPOINT: 1025px–1280px — Laptops
   ================================================================ */
@media (min-width: 1025px) and (max-width: 1280px) {
  .z-hero-grid {
    gap: 32px;
    padding: 16px 32px 40px;
  }

  .z-hero-headline {
    font-size: clamp(46px, 5vw, 72px);
  }
}

/* ================================================================
   BREAKPOINT: 1400px+ — Large Desktops
   ================================================================ */
@media (min-width: 1400px) {
  .container,
  .container-lg,
  .container-md,
  .container-sm,
  .container-xl,
  .container-xxl {
    max-width: 1450px;
  }

  .z-hero-grid {
    max-width: 1400px;
  }
}

/* ================================================================
   BREAKPOINT: 1600px+ — Wide Desktops
   ================================================================ */
@media (min-width: 1600px) {
  .container,
  .container-lg,
  .container-md,
  .container-sm,
  .container-xl,
  .container-xxl {
    max-width: 1560px;
  }

  .z-hero-grid {
    max-width: 1500px;
    gap: 64px;
  }

  .zorpido-services .container {
    max-width: 1560px;
  }

  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  }

  /* Larger spacing on wide screens */
  .zorpido-featured-slider,
  .zorpido-why-choose,
  .loyalty-program-section,
  .zorpido-gallery-section,
  .zorpido-testimonials {
    padding-top: 6rem;
    padding-bottom: 6rem;
  }
}

/* ================================================================
   BREAKPOINT: 2560px+ — Ultra-Wide / 4K Displays
   ================================================================ */
@media (min-width: 2560px) {
  .container,
  .container-lg,
  .container-md,
  .container-sm,
  .container-xl,
  .container-xxl {
    max-width: 1800px;
  }

  body {
    font-size: 16px;
  }

  .z-hero-grid {
    max-width: 1700px;
    gap: 80px;
  }

  .z-hero-headline {
    font-size: 96px;
  }

  .zorpido-services .container {
    max-width: 1800px;
  }

  /* Larger section padding */
  .zorpido-featured-slider,
  .zorpido-why-choose,
  .loyalty-program-section,
  .zorpido-gallery-section,
  .zorpido-testimonials {
    padding-top: 8rem;
    padding-bottom: 8rem;
  }

  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 2rem;
  }

  .featured-slider-wrapper {
    max-width: 1800px;
  }
}

/* ================================================================
   LANDSCAPE ORIENTATION — Phones
   ================================================================ */
@media (max-height: 500px) and (orientation: landscape) {
  #hero {
    min-height: auto;
  }

  .z-hero-grid {
    grid-template-columns: 1fr 1fr;
    padding: 10px 24px 20px;
    gap: 24px;
  }

  .z-hero-left {
    text-align: left;
    align-items: flex-start;
    order: 1;
  }

  .z-hero-right {
    order: 2;
    max-width: 250px;
  }

  .z-hero-headline {
    font-size: 36px !important;
  }

  .z-hero-tagline {
    font-size: 13px;
    margin-bottom: 16px;
  }

  .z-top-bar {
    padding: 8px 24px;
  }

  .z-features-band {
    margin-top: 20px;
  }

  /* Reduce navbar height */
  #futuristic-navbar .container {
    padding-top: 6px;
    padding-bottom: 6px;
  }

  #futuristic-navbar .zorpido-logo-img {
    height: 32px;
  }

  .menu-hero-section {
    min-height: 300px;
  }
}

/* ================================================================
   LANDSCAPE ORIENTATION — Tablets
   ================================================================ */
@media (min-height: 501px) and (max-height: 800px) and (orientation: landscape) {
  #hero {
    min-height: auto;
  }

  .z-hero-grid {
    padding-bottom: 30px;
  }

  .z-features-band {
    margin-top: 30px;
  }
}

/* ================================================================
   FOLDABLE DEVICES
   ================================================================ */
@media (horizontal-viewport-segments: 2) {
  .z-hero-grid {
    grid-template-columns: 1fr 1fr;
    gap: env(viewport-segment-left 1 0, 24px);
  }

  .pos-container {
    grid-template-columns: 1fr 1fr;
  }
}

/* ================================================================
   HIGH DPI / RETINA DISPLAYS
   ================================================================ */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  #futuristic-navbar::before {
    height: 2px;
  }
}

/* ================================================================
   REDUCED MOTION — Accessibility
   ================================================================ */
@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;
  }
}

/* ================================================================
   PRINT STYLES
   ================================================================ */
@media print {
  #futuristic-navbar,
  .pos-sidebar,
  .floating-elements,
  .floating-quotes,
  .gallery-decorations,
  .z-dot-pattern,
  .z-arch,
  #nb-overlay {
    display: none !important;
  }

  body {
    background: white !important;
    color: black !important;
    font-size: 12pt;
  }

  main {
    padding-top: 0 !important;
  }

  .pos-main {
    margin-left: 0 !important;
    width: 100% !important;
  }

  a[href]::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
    color: #666;
  }
}

/* ================================================================
   RESPONSIVE UTILITY CLASSES
   ================================================================ */

/* Hide on specific breakpoints */
@media (max-width: 480px) {
  .hide-mobile { display: none !important; }
}
@media (min-width: 481px) and (max-width: 768px) {
  .hide-tablet { display: none !important; }
}
@media (min-width: 769px) {
  .hide-desktop { display: none !important; }
}

/* Responsive text alignment */
@media (max-width: 768px) {
  .text-center-mobile { text-align: center !important; }
}
@media (max-width: 480px) {
  .text-center-phone { text-align: center !important; }
}

/* Full width on mobile */
@media (max-width: 768px) {
  .full-width-mobile {
    width: 100% !important;
    max-width: 100% !important;
  }
}

/* Stack flex items on mobile */
@media (max-width: 576px) {
  .stack-mobile {
    flex-direction: column !important;
  }
  .stack-mobile > * {
    width: 100% !important;
  }
}

/* Responsive gap */
.gap-responsive {
  gap: clamp(0.75rem, 2vw, 1.5rem);
}

/* Responsive padding */
.p-responsive {
  padding: var(--resp-space-md);
}

.px-responsive {
  padding-left: var(--resp-space-md);
  padding-right: var(--resp-space-md);
}

.py-responsive {
  padding-top: var(--resp-space-md);
  padding-bottom: var(--resp-space-md);
}
