/**
 * Full Responsive Layout & Desktop E-Commerce Styles for Vacheh Market
 * - Mobile (<= 767px): 100% Native Mobile-First Experience
 * - Tablet & Desktop (>= 768px): Full-Width Responsive Supermarket Layout
 */

/* ==========================================================
   1. UNWRAP MOCKUP CONTAINERS ON ALL DEVICES
   ========================================================== */
#android-device-wrapper,
#android-phone-frame,
#android-screen-view {
  display: contents !important;
}

.android-hardware-element,
#desktop-companion-card,
#android-status-bar {
  display: none !important;
}

/* ==========================================================
   2. DESKTOP & TABLET FULL-WIDTH RESPONSIVE LAYOUT (>= 768px)
   ========================================================== */
@media (min-width: 768px) {
  html {
    background-color: #f7faf5 !important;
    background-image: none !important;
    min-height: 100vh !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
  }

  body {
    background-color: #f7faf5 !important;
    background-image: none !important;
    min-height: 100vh !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
  }

  /* Custom subtle scrollbar on desktop */
  ::-webkit-scrollbar {
    display: block;
    width: 8px;
    height: 8px;
  }
  ::-webkit-scrollbar-track {
    background: #f1f4f0;
  }
  ::-webkit-scrollbar-thumb {
    background: #cbd2c9;
    border-radius: 9999px;
  }
  ::-webkit-scrollbar-thumb:hover {
    background: #a33900;
  }

  /* Main Container Centered Max-Width on Desktop */
  main {
    max-width: 1440px;
    margin-left: auto;
    margin-right: auto;
    padding-top: 132px !important;
    padding-bottom: 48px !important;
  }

  /* Hide Mobile Bottom Navigation Bar on Desktop (moved to Top Header) */
  nav[data-active-classes] {
    display: none !important;
  }

  /* ==========================================================
     Desktop Centered Dialogs & Modals
     ========================================================== */
  [role="dialog"],
  [id$="-modal"],
  #checkout-confirm-modal {
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    max-width: none !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 24px !important;
  }

  [id$="-backdrop"],
  [role="dialog"] > .fixed,
  [role="dialog"] > .backdrop-blur-sm,
  #modal-backdrop,
  #checkout-modal-backdrop {
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
  }

  /* Standard Modal Sheets on Desktop become Centered Rounded Modals */
  [id$="-sheet"],
  [role="dialog"] > [id$="-sheet"],
  #checkout-modal-sheet {
    position: relative !important;
    width: 100% !important;
    max-width: 560px !important;
    max-height: 88vh !important;
    border-radius: 28px !important;
    margin: auto !important;
    box-shadow: 0 25px 70px -15px rgba(0, 0, 0, 0.28) !important;
  }

  /* Wider Desktop Modals for Product Detail, Categories, Club, Location, Vouchers & Support */
  #product-modal-sheet,
  #category-modal-sheet,
  #club-sheet,
  #vouchers-sheet,
  #orders-sheet,
  #support-sheet {
    max-width: 720px !important;
  }

  #support-sheet {
    height: 85vh !important;
  }

  #modal-sheet,
  #onboarding-modal-sheet {
    max-width: 680px !important;
  }

  /* Hide mobile drag handle inside desktop modals */
  [id$="-sheet"] .sheet-drag-handle,
  [id$="-sheet"] > div:first-child > .w-12.h-1\.5 {
    display: none !important;
  }

  /* Fullscreen Map Step inside Desktop Modal */
  [id$="-sheet"].modal-sheet-fullscreen,
  #modal-sheet.modal-sheet-fullscreen,
  #onboarding-modal-sheet.modal-sheet-fullscreen {
    max-width: 880px !important;
    height: 82vh !important;
    max-height: 82vh !important;
    border-radius: 28px !important;
  }

  /* Toast Notification on Desktop */
  #address-toast {
    max-width: 420px !important;
    left: 50% !important;
    right: auto !important;
    transform: translateX(-50%) !important;
  }
}

/* ==========================================================
   3. SKELETON SCREEN LOADING SHIMMER
   Smooth placeholder shimmer across Mobile and Desktop
   ========================================================== */
.product-skeleton-card {
  position: relative;
  overflow: hidden;
  user-select: none;
  pointer-events: none;
}

.product-skeleton-card::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  transform: translateX(120%);
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.45) 50%,
    rgba(255, 255, 255, 0) 100%
  );
  animation: skeleton-swipe 1.6s infinite cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}

@keyframes skeleton-swipe {
  0% {
    transform: translateX(120%);
  }
  100% {
    transform: translateX(-120%);
  }
}

/* Custom Styled Range Slider */
#price-range-slider {
  -webkit-appearance: none;
  appearance: none;
  background: #e2e8f0;
  border-radius: 9999px;
  height: 8px;
}

#price-range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #a33900;
  border: 3px solid #ffffff;
  box-shadow: 0 2px 6px rgba(163, 57, 0, 0.4);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

#price-range-slider::-webkit-slider-thumb:hover,
#price-range-slider::-webkit-slider-thumb:active {
  transform: scale(1.18);
  box-shadow: 0 3px 10px rgba(163, 57, 0, 0.55);
}

#price-range-slider::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #a33900;
  border: 3px solid #ffffff;
  box-shadow: 0 2px 6px rgba(163, 57, 0, 0.4);
  cursor: pointer;
}

/* ==========================================================
   4. FULLSCREEN MAP MODAL MODE
   ========================================================== */
.modal-sheet-fullscreen {
  display: flex !important;
  flex-direction: column !important;
}

@media (max-width: 767px) {
  .modal-sheet-fullscreen {
    top: 0 !important;
    bottom: 0 !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    border-top-left-radius: 0 !important;
    border-top-right-radius: 0 !important;
    border-radius: 0 !important;
    border-top: none !important;
  }
}

.modal-sheet-fullscreen .sheet-drag-handle {
  display: none !important;
}

.modal-sheet-fullscreen .sheet-scroll-container {
  height: calc(100% - 56px) !important;
  max-height: calc(100% - 56px) !important;
  flex: 1 1 auto !important;
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
}

/* Ensure .hidden elements inside location/onboarding modals are always hidden */
.modal-sheet-fullscreen .hidden,
#location-modal .hidden,
#onboarding-modal .hidden {
  display: none !important;
}

/* Dedicated Map Steps: Fill full vertical viewport seamlessly when visible */
.modal-sheet-fullscreen #map-section:not(.hidden),
.modal-sheet-fullscreen #location-step-map:not(.hidden),
.modal-sheet-fullscreen #onboarding-step-map:not(.hidden) {
  display: flex !important;
  flex-direction: column !important;
  flex: 1 1 100% !important;
  height: 100% !important;
  min-height: 0 !important;
  overflow: hidden !important;
}

.modal-sheet-fullscreen #real-map-container,
.modal-sheet-fullscreen #onboarding-map-container {
  flex: 1 1 0% !important;
  width: 100% !important;
  min-height: 260px !important;
  max-height: none !important;
  height: auto !important;
  border-radius: 0 !important;
  border-left: 0 !important;
  border-right: 0 !important;
}

.modal-sheet-fullscreen #leaflet-location-map,
.modal-sheet-fullscreen #onboarding-leaflet-map {
  width: 100% !important;
  height: 100% !important;
}

/* Details Steps: Scrollable forms */
.modal-sheet-fullscreen #saved-addresses-section:not(.hidden),
.modal-sheet-fullscreen #location-step-details:not(.hidden),
.modal-sheet-fullscreen #onboarding-step-details:not(.hidden) {
  flex: 1 1 0% !important;
  min-height: 0 !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
}
