/* =============================================================================
   NATURISTA — RESPONSIVE FIXES & UI CONSISTENCY
   Addresses: horizontal scroll, card uniformity, mobile UX, inline-style
   replacements, touch-device hover, cross-browser prefixes.
   Mobile-first: base styles target smallest screens; media queries scale up.
   ============================================================================= */

/* =============================================================================
   0. CSS CUSTOM PROPERTIES
   ============================================================================= */
:root {
  --rf-sidebar-width: 420px;
  --rf-mobile-nav-h: 70px;
  --rf-mobile-header-h: 72px;
  --rf-card-radius: 10px;
  --rf-transition: all 0.3s ease;
  --rf-green: #81b214;
  --rf-green-dark: #6a9611;
}

/* =============================================================================
   1. GLOBAL — Prevent horizontal overflow on every device
   ============================================================================= */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  overflow-x: hidden;
  scroll-behavior: smooth;
}

body {
  overflow-x: hidden;
  max-width: 100vw;
  -webkit-text-size-adjust: 100%; /* prevent iOS font bump on orientation change */
}

img,
video,
iframe,
embed,
object {
  max-width: 100%;
  height: auto;
}

/* =============================================================================
   2. BODY OFFSET — compensate for fixed mobile header & bottom nav
   ============================================================================= */
@media (max-width: 1199px) {
  body {
    padding-top: var(--rf-mobile-header-h) !important;
    padding-bottom: var(--rf-mobile-nav-h) !important;
  }
}

@media (min-width: 1200px) {
  body {
    padding-top: 0 !important;
    padding-bottom: 0 !important;
  }
}

/* Safe area insets for notched devices (iPhone X +) */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  @media (max-width: 1199px) {
    body {
      padding-bottom: calc(var(--rf-mobile-nav-h) + env(safe-area-inset-bottom)) !important;
    }
    .mobile-bottom-nav {
      padding-bottom: calc(12px + env(safe-area-inset-bottom));
      height: calc(var(--rf-mobile-nav-h) + env(safe-area-inset-bottom));
    }
  }
}

/* =============================================================================
   3. LANG SWITCHER FLOATING BUTTON
   (moved here from main.blade.php <style> block)
   ============================================================================= */
.lang-switcher-floating {
  position: fixed;
  bottom: 80px;
  right: 20px;
  z-index: 9999;
}

.lang-switcher-btn {
  display: -webkit-inline-flex;
  display: inline-flex;
  -webkit-align-items: center;
  align-items: center;
  gap: 6px;
  background: #2d7a3e;
  color: #fff;
  width: 84px;
  height: 39px;
  border-radius: 50px;
  padding: 8px 14px;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  -webkit-box-shadow: 0 4px 14px rgba(45, 122, 62, 0.4);
  box-shadow: 0 4px 14px rgba(45, 122, 62, 0.4);
  -webkit-transition: var(--rf-transition);
  transition: var(--rf-transition);
}

.lang-switcher-btn:hover {
  background: #1e5c2c;
  color: #fff;
  -webkit-transform: translateY(-2px);
  transform: translateY(-2px);
  -webkit-box-shadow: 0 6px 20px rgba(45, 122, 62, 0.5);
  box-shadow: 0 6px 20px rgba(45, 122, 62, 0.5);
}

.lang-flag {
  font-size: 16px;
  line-height: 1;
  height: 30px;
}

.lang-label {
  letter-spacing: 0.5px;
}

@media (max-width: 1199px) {
  .lang-switcher-floating {
    bottom: calc(var(--rf-mobile-nav-h) + 10px);
    right: 12px;
  }
}

@media (max-width: 374px) {
  .lang-switcher-floating {
    bottom: calc(var(--rf-mobile-nav-h) + 8px);
    right: 8px;
  }
}

/* =============================================================================
   4. PRODUCT CARD FIXES
   ============================================================================= */

/* 4a. Remove the inline margin-right on product title links */
.tpproduct__title a {
  margin-right: 0 !important;
  /* Already 2-line clamped — let overflow handle the shopping-icon overlap */
}

/* 4b. Uniform image area using aspect-ratio */
.tpproduct__thumb {
  overflow: hidden;
  border-radius: var(--rf-card-radius) var(--rf-card-radius) 0 0;
  position: relative;
  aspect-ratio: 1 / 1; /* square crop zone */
  padding: 0; /* override the inline 20px 20px */
}

.tpproduct__thumb > a,
.tpproduct__thumb > a:first-child {
  display: block;
  width: 100%;
  height: 100%;
}

.tpproduct__thumb img:not(.tpproduct__thumb-img) {
  width: 100%;
  height: 100%;
  -o-object-fit: contain;
  object-fit: contain;
  padding: 16px;
}

/* 4c. Hover-overlay image: fill the same space */
.tpproduct__thumb-img {
  width: 100%;
  height: 100%;
  -o-object-fit: contain;
  object-fit: contain;
  padding: 16px;
}

/* 4d. Payzy logo beside installments text */
.payzy-logo {
  width: 50px;
  height: auto;
  vertical-align: middle;
  -webkit-user-select: none;
  user-select: none;
}

/* 4e. Touch devices: product hover area always visible
   (hover pseudo-state doesn't exist on touchscreens — add-to-cart was
   completely inaccessible without tapping twice) */
@media (hover: none), (pointer: coarse) {
  .tpproduct__hover-text {
    position: static !important;
    opacity: 1 !important;
    visibility: visible !important;
    bottom: auto !important;
    border: none !important;
    border-top: none !important;
    border-radius: 0 0 var(--rf-card-radius) var(--rf-card-radius) !important;
    -webkit-box-shadow: none !important;
    box-shadow: none !important;
    -webkit-transform: none !important;
    transform: none !important;
    padding: 10px 15px 15px !important;
  }

  .tpproduct__shopping a {
    opacity: 1 !important;
    visibility: visible !important;
    -webkit-transform: translateY(0) !important;
    transform: translateY(0) !important;
  }
}

/* 4f. Product card: equal height columns in the grid */
.tpproduct__shop-item .col-xl-3,
.tpproduct__shop-item .col-xl-4,
.tpproduct__shop-item [class*="col-"] {
  display: -webkit-flex;
  display: flex;
}

.tpproduct {
  display: -webkit-flex;
  display: flex;
  -webkit-flex-direction: column;
  flex-direction: column;
  width: 100%;
}

.tpproduct__content {
  -webkit-flex: 1;
  flex: 1;
}

/* 4g. Sold-count badge — wrap on very small screens */
.product-sold-count {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* =============================================================================
   5. BLOG CARD FIXES — uniform height & image crop
   ============================================================================= */

/* 5a. Full-height flex card */
.tpblog__item {
  display: -webkit-flex;
  display: flex;
  -webkit-flex-direction: column;
  flex-direction: column;
  height: 100%;
  border-radius: var(--rf-card-radius);
  overflow: hidden;
}

/* 5b. Image: fixed height with cover crop so all thumbnails align */
.tpblog__thumb {
  -webkit-flex-shrink: 0;
  flex-shrink: 0;
  overflow: hidden;
}

.tpblog__thumb img {
  width: 100%;
  height: 220px;
  -o-object-fit: cover;
  object-fit: cover;
  -webkit-transition: -webkit-transform 0.8s ease;
  transition: transform 0.8s ease;
  display: block;
}

.tpblog__item:hover .tpblog__thumb img {
  -webkit-transform: scale(1.05);
  transform: scale(1.05);
}

/* 5c. Content area: flex-grow so "Read More" sits at the bottom */
.tpblog__wrapper {
  -webkit-flex: 1;
  flex: 1;
  display: -webkit-flex;
  display: flex;
  -webkit-flex-direction: column;
  flex-direction: column;
}

.tpblog__details {
  margin-top: auto;
  padding-top: 8px;
}

/* 5d. Ensure Bootstrap row stretches columns to equal height */
.tpblog__row,
.blog-row-equal {
  -webkit-align-items: stretch;
  align-items: stretch;
}

/* 5e. Responsive image heights */
@media (max-width: 1199px) {
  .tpblog__thumb img {
    height: 200px;
  }
}

@media (max-width: 767px) {
  .tpblog__thumb img {
    height: 180px;
  }
}

@media (max-width: 575px) {
  .tpblog__thumb img {
    height: 160px;
  }
}

/* =============================================================================
   6. CATEGORY CARD FIXES — uniform height
   ============================================================================= */
.category__item {
  display: -webkit-flex;
  display: flex;
  -webkit-flex-direction: column;
  flex-direction: column;
  -webkit-align-items: center;
  align-items: center;
  -webkit-justify-content: center;
  justify-content: center;
  min-height: 150px;
  height: 100%;
}

.category__thumb img {
  width: 80px;
  height: 80px;
  -o-object-fit: cover;
  object-fit: cover;
  border-radius: 50%;
  -webkit-flex-shrink: 0;
  flex-shrink: 0;
}

/* Category title: clamp to 2 lines so cards stay aligned */
.category__title {
  overflow: hidden;
  text-overflow: ellipsis;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  display: -webkit-box;
}

/* =============================================================================
   7. PRODUCT-DETAILS PAGE — CSS classes replacing inline styles
   ============================================================================= */

/* Main product image */
.product-detail__main-img {
  max-width: 400px;
  width: 100%;
  height: auto;
  -o-object-fit: cover;
  object-fit: cover;
  border-radius: 8px;
  display: block;
  margin: 0 auto;
}

/* Thumbnail wrapper */
.product-detail__thumb {
  cursor: pointer;
  width: 80px;
  height: 80px;
  overflow: hidden;
  border-radius: 6px;
  border: 2px solid transparent;
  -webkit-transition: border-color 0.2s ease;
  transition: border-color 0.2s ease;
  -webkit-flex-shrink: 0;
  flex-shrink: 0;
}

.product-detail__thumb:hover,
.product-detail__thumb.active {
  border-color: var(--rf-green);
}

/* Thumbnail image */
.product-detail__thumb img {
  width: 100%;
  height: 100%;
  -o-object-fit: cover;
  object-fit: cover;
  display: block;
}

@media (max-width: 767px) {
  .product-detail__main-img {
    max-width: 100%;
  }

  .product-detail__thumb {
    width: 60px;
    height: 60px;
  }
}

@media (max-width: 374px) {
  .product-detail__thumb {
    width: 52px;
    height: 52px;
  }
}

/* =============================================================================
   8. CART / WISHLIST SIDEBAR — Responsive widths
   ============================================================================= */

/* Tablet portrait (576px–767px): narrower than desktop but not full-width */
@media (min-width: 576px) and (max-width: 767px) {
  .tpcartinfo,
  .tpwishlistinfo {
    width: 360px;
    right: -360px;
  }

  .tpcartinfo.tp-sidebar-opened,
  .tpwishlistinfo.tp-sidebar-opened {
    right: 0;
  }
}

/* =============================================================================
   9. SHOP SIDEBAR — Mobile behaviour
   ============================================================================= */

/* On non-xl screens the sidebar stacks above the product grid */
@media (max-width: 1199px) {
  .tpshop__leftbar {
    margin-bottom: 24px;
  }

  /* Horizontal scrollable category chip row */
  .tpshop__widget .form-check {
    display: inline-flex;
  }
}

/* Price range slider — full width on mobile */
@media (max-width: 575px) {
  .productsidebar__range {
    width: 100%;
  }

  #slider-range {
    width: 100% !important;
  }
}

/* =============================================================================
   10. CHECKOUT PAGE — Responsive tables & toast placement
   ============================================================================= */

/* Shipping table: stack columns on mobile */
@media (max-width: 767px) {
  #shippingRow th,
  #shippingRow td {
    display: block;
    width: 100% !important;
  }

  .shipping-cost-wrapper {
    -webkit-align-items: flex-start;
    align-items: flex-start;
    margin-top: 12px;
  }

  .shipping-detail-item {
    -webkit-flex-wrap: wrap;
    flex-wrap: wrap;
  }
}

/* Toast z-index: always above sidebars (sidebar is z-index 9999) */
.toast-container {
  z-index: 10001 !important;
}

/* =============================================================================
   11. FOOTER — Mobile spacing
   ============================================================================= */
@media (max-width: 1199px) {
  .site-footer {
    /* No extra margin needed — body bottom padding handles the nav gap */
    margin-bottom: 0;
  }
}

/* =============================================================================
   12. BREADCRUMB — Mobile font scaling
   ============================================================================= */
@media (max-width: 575px) {
  .tp-breadcrumb__content h1,
  .tp-breadcrumb__content .tp-breadcrumb__title {
    font-size: clamp(18px, 5vw, 28px);
  }
}

/* =============================================================================
   13. HORIZONTAL SCROLL HARDENING
   — targets elements that commonly break out of viewport
   ============================================================================= */

/* Prevent Swiper from causing horizontal scroll */
.swiper {
  overflow: hidden;
}

.swiper-wrapper {
  max-width: 100%;
}

/* Tables inside cards/modals */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Ensure no fixed-width element breaks narrow screens */
@media (max-width: 479px) {
  .tpcart,
  .tpcart__item {
    min-width: 0;
  }

  /* Very small screens: reduce cart padding */
  .tpcart__item {
    gap: 10px;
    padding: 10px;
  }

  .tpcart__img {
    width: 60px !important;
    height: 60px !important;
  }
}

/* =============================================================================
   14. CROSS-BROWSER PREFIXES — Flex & Transform
   ============================================================================= */

/* Flexbox — older Safari & Chrome */
.tpcart__item,
.tpcart__content,
.category__item,
.tpblog__item,
.tpblog__wrapper,
.tpproduct,
.header__info,
.mobile-bottom-nav {
  display: -webkit-box;
  display: -webkit-flex;
  display: -ms-flexbox;
  display: flex;
}

/* -webkit- for backdrop-filter (Safari < 15) */
.tpsearchbar {
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

/* =============================================================================
   15. FONT SCALING — tiny viewports
   ============================================================================= */
@media (max-width: 374px) {
  html {
    font-size: 13.5px;
  }

  .tpproduct__price span {
    font-size: 15px;
  }

  .tpproduct__title {
    font-size: 13px;
  }
}

/* =============================================================================
   16. PRINT STYLES — remove interactive chrome
   ============================================================================= */
@media print {
  .mobile-bottom-nav,
  .lang-switcher-floating,
  .tpcartinfo,
  .tpwishlistinfo,
  .tpsearchbar,
  .tpsideinfo,
  #header-sticky-2 {
    display: none !important;
  }

  body {
    padding: 0 !important;
  }
}
