/* ============================================================
   Golden Thread - Storefront & Customer Responsive Stylesheet
   شركة الخيط الذهبي - أنماط التجاوب للمتجر وبوابة العملاء
   Mobile First Architecture - Luxury White & Gold
   ============================================================ */

/* ------------------------------------------------------------
   1. Root Reset & Base Fluid System
   ------------------------------------------------------------ */
html {
  font-size: 15px;
  -webkit-text-size-adjust: 100%;
}

body {
  overflow-x: hidden !important;
  width: 100%;
  position: relative;
  background-color: var(--background);
  color: var(--text-primary);
}

/* Prevent horizontal overflow on any direct containers */
.container,
.container-fluid,
.container-sm,
.container-md,
.container-lg,
.container-xl,
.container-xxl {
  width: 100%;
  padding-right: 1rem;
  padding-left: 1rem;
  margin-right: auto;
  margin-left: auto;
}

/* Large & Ultra-wide screen boundary (2K, 4K) */
@media (min-width: 1920px) {
  .container {
    max-width: 1560px;
  }
}

@media (min-width: 2560px) {
  .container {
    max-width: 1800px;
  }
}

/* Fluid responsive typography */
h1, .h1 { font-size: clamp(1.6rem, 4vw + 0.5rem, 2.8rem); }
h2, .h2 { font-size: clamp(1.35rem, 3vw + 0.3rem, 2.2rem); }
h3, .h3 { font-size: clamp(1.15rem, 2vw + 0.2rem, 1.75rem); }
h4, .h4 { font-size: clamp(1.05rem, 1.5vw + 0.1rem, 1.4rem); }
h5, .h5 { font-size: clamp(0.95rem, 1vw + 0.1rem, 1.15rem); }

/* Images and Media Fluidity */
img, svg, video, canvas, iframe {
  max-width: 100%;
  height: auto;
}

/* Touch Friendly Minimum Target Size */
button, 
a.btn, 
.nav-link,
.dropdown-item,
.form-check-input,
.page-link {
  touch-action: manipulation;
}

/* ------------------------------------------------------------
   2. Public Navigation (Navbar) Responsive System - Royal Gold Theme
   ------------------------------------------------------------ */
.navbar-gt {
  min-height: var(--navbar-height, 70px);
  padding: 0.65rem 0;
  position: sticky;
  top: 0;
  z-index: 1030;
  background: linear-gradient(135deg, #D4AF37 0%, #C59A27 28%, #A88416 70%, #8C6509 100%) !important;
  border-top: 1px solid rgba(255, 255, 255, 0.35) !important;
  border-bottom: 1px solid rgba(140, 101, 9, 0.45) !important;
  box-shadow: 0 4px 20px rgba(140, 101, 9, 0.35) !important;
  transition: all 0.3s ease;
}

.navbar-gt.scrolled {
  background: linear-gradient(135deg, #C59A27 0%, #A87E12 50%, #825C05 100%) !important;
  box-shadow: 0 6px 26px rgba(120, 80, 5, 0.45) !important;
}

.navbar-brand-gt {
  display: flex;
  align-items: center;
  gap: clamp(0.5rem, 0.4rem + 0.4vw, 0.85rem);
  text-decoration: none;
  color: #FFFFFF !important;
}

.navbar-brand-gt .brand-title {
  color: #FFFFFF !important;
}

.navbar-brand-gt .brand-subtitle {
  color: rgba(255, 255, 255, 0.9) !important;
}

.navbar-brand-gt .logo-icon {
  width: clamp(38px, 34px + 0.6vw, 44px);
  height: clamp(38px, 34px + 0.6vw, 44px);
  background: #FFFFFF !important;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(1.15rem, 1.05rem + 0.3vw, 1.35rem);
  color: #8C6509 !important;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  flex-shrink: 0;
}

/* Mobile Toggles */
.navbar-toggler {
  padding: 0.5rem;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.22) !important;
  border: 1px solid rgba(255, 255, 255, 0.45) !important;
  color: #FFFFFF !important;
  transition: var(--transition-fast);
}

.navbar-toggler:hover,
.navbar-toggler:focus {
  background: rgba(255, 255, 255, 0.35) !important;
  border-color: #FFFFFF !important;
  color: #FFFFFF !important;
  outline: none;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.4);
}

.cart-btn, .notif-btn {
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.22) !important;
  border: 1px solid rgba(255, 255, 255, 0.45) !important;
  color: #FFFFFF !important;
  font-size: 1.15rem;
  position: relative;
  transition: var(--transition-fast);
}

.cart-btn:hover, .notif-btn:hover {
  background: #FFFFFF !important;
  border-color: #FFFFFF !important;
  color: #8C6509 !important;
  transform: translateY(-1px);
}

.cart-count {
  position: absolute;
  top: -5px;
  left: -5px;
  right: auto;
  background: #FFFFFF !important;
  color: #8C6509 !important;
  font-weight: 900;
  font-size: 0.72rem;
  min-width: 20px;
  height: 20px;
  padding: 0 4px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.notif-count {
  position: absolute;
  top: -5px;
  left: -5px;
  right: auto;
  background: #DC3545 !important;
  color: #FFFFFF !important;
  font-weight: 800;
  font-size: 0.68rem;
  min-width: 19px;
  height: 19px;
  padding: 0 4px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

/* Mobile Nav Menu Drawer (Collapse) */
@media (max-width: 991.98px) {
  #navMenu {
    background: linear-gradient(145deg, #C59A27 0%, #A87E12 50%, #825C05 100%) !important;
    border: 1px solid rgba(255, 255, 255, 0.35) !important;
    border-radius: 14px;
    margin-top: 0.75rem;
    padding: 1.25rem 1rem;
    box-shadow: 0 14px 40px rgba(0, 0, 0, 0.35);
  }

  .navbar-nav {
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.25);
  }

  .nav-link-gt {
    padding: 0.75rem 1rem !important;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    color: #FFFFFF !important;
    transition: var(--transition-fast);
    min-height: 44px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  }

  .nav-link-gt:hover,
  .nav-link-gt.active {
    background: rgba(255, 255, 255, 0.22) !important;
    color: #FFFFFF !important;
  }

  #navMenu .d-flex.align-items-center.gap-3 {
    flex-direction: column;
    align-items: stretch !important;
    gap: 0.65rem !important;
  }

  #navMenu .d-flex.align-items-center.gap-3 .btn {
    width: 100%;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
  }

  #navMenu .dropdown {
    width: 100%;
  }

  #navMenu .dropdown > button {
    width: 100%;
    min-height: 44px;
    justify-content: space-between;
  }

  #navMenu .dropdown-menu {
    position: static !important;
    transform: none !important;
    width: 100% !important;
    margin-top: 0.5rem;
  }
}

/* ------------------------------------------------------------
   3. Dropdowns Boundary Protection
   ------------------------------------------------------------ */
.dropdown-menu {
  max-width: calc(100vw - 20px) !important;
  max-height: 80vh;
  overflow-y: auto;
  border-radius: var(--radius-md) !important;
  background: #FFFFFF !important;
  border: 1px solid var(--border-color) !important;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08) !important;
}

.dropdown-menu-start {
  right: 0 !important;
  left: auto !important;
}

@media (max-width: 575.98px) {
  .dropdown-menu {
    width: min(320px, calc(100vw - 20px)) !important;
  }
}

/* ------------------------------------------------------------
   4. Hero Carousel & Slides Fluidity
   ------------------------------------------------------------ */
.hero-carousel,
.hero-slide-wrap {
  width: 100%;
  overflow: hidden;
}

.hero-slide-wrap {
  min-height: clamp(380px, 50vh, 580px) !important;
  display: flex;
  align-items: center;
}

@media (max-width: 767.98px) {
  .hero-slide-wrap {
    min-height: 380px !important;
    text-align: center;
  }

  .hero-slide-wrap .col-lg-7 {
    text-align: center !important;
  }

  .hero-slide-wrap .lead {
    font-size: 0.95rem !important;
    margin-left: auto;
    margin-right: auto;
  }

  .hero-slide-wrap .d-flex.flex-wrap {
    justify-content: center;
  }

  .hero-slide-wrap .btn-lg {
    padding: 0.6rem 1.25rem !important;
    font-size: 0.95rem !important;
    min-height: 44px;
    width: 100%;
  }

  .carousel-control-prev,
  .carousel-control-next {
    display: none;
  }
}

/* ------------------------------------------------------------
   5. Product Catalog & Grid Fluidity
   ------------------------------------------------------------ */
.product-card {
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s ease, border-color 0.3s ease;
  position: relative;
  background: #FFFFFF !important;
  border: 1px solid var(--border-color) !important;
}

.product-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 28px rgba(201, 162, 39, 0.16);
  border-color: var(--primary-gold) !important;
}

.product-img-wrap {
  height: clamp(180px, 22vw, 240px) !important;
  background: #F9F9F9 !important;
}

.product-img-wrap img {
  transition: transform 0.4s ease;
}

.product-card:hover .product-img-wrap img {
  transform: scale(1.05);
}

.filter-mobile-toggle {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  background: #FFFFFF;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.5rem 1rem;
}

@media (max-width: 991.98px) {
  .filter-sidebar-wrapper {
    margin-bottom: 1.5rem;
  }
}

/* ------------------------------------------------------------
   6. Product Details & Gallery Fluidity
   ------------------------------------------------------------ */
.product-gallery .main-image-wrap {
  height: clamp(280px, 45vw, 460px) !important;
  max-width: 100%;
  background: #FFFFFF;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

.product-gallery .main-image-wrap img {
  max-height: 100%;
  object-fit: contain;
}

.gallery-thumbs-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--primary-gold) var(--surface-soft);
}

.gallery-thumbs-wrapper::-webkit-scrollbar {
  height: 4px;
}

.gallery-thumbs-wrapper::-webkit-scrollbar-thumb {
  background: var(--primary-gold);
  border-radius: 4px;
}

/* Attribute Buttons (Sizes & Colors) */
.variant-btn {
  min-height: 42px;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: #FFFFFF;
  color: var(--text-primary);
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
}

.variant-btn:hover,
.variant-btn.active {
  border-color: var(--primary-gold);
  background: #F8F6EF;
  color: var(--primary-gold-dark);
}

/* Quantity Counter Input */
.qty-stepper {
  display: flex;
  align-items: center;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: #FFFFFF;
  overflow: hidden;
  max-width: 160px;
}

.qty-stepper button {
  width: 44px;
  height: 44px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
}

.qty-stepper button:hover {
  background: var(--surface-hover);
  color: var(--primary-gold-dark);
}

.qty-stepper input {
  width: 60px;
  height: 44px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  text-align: center;
  font-weight: 700;
  font-size: 1rem;
  outline: none;
}

/* ------------------------------------------------------------
   7. Tables & Responsive Scroll Containers
   ------------------------------------------------------------ */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 0;
  border-radius: inherit;
  scrollbar-width: thin;
  scrollbar-color: rgba(201, 162, 39, 0.3) var(--surface-soft);
  background: #FFFFFF;
}

.table-responsive::-webkit-scrollbar {
  height: 5px;
}

.table-responsive::-webkit-scrollbar-track {
  background: var(--surface-soft);
}

.table-responsive::-webkit-scrollbar-thumb {
  background: rgba(201, 162, 39, 0.4);
  border-radius: 4px;
}

.table-responsive .table {
  width: 100%;
  margin-bottom: 0;
  vertical-align: middle;
}

.table-responsive .table th,
.table-responsive .table td {
  white-space: nowrap;
  padding: 0.75rem 1rem;
}

/* ------------------------------------------------------------
   8. Modals Mobile Responsiveness
   ------------------------------------------------------------ */
.modal-dialog {
  max-width: min(600px, calc(100vw - 20px)) !important;
  margin: 1rem auto !important;
}

.modal-dialog.modal-lg {
  max-width: min(840px, calc(100vw - 20px)) !important;
}

.modal-dialog.modal-xl {
  max-width: min(1140px, calc(100vw - 20px)) !important;
}

.modal-content {
  max-height: calc(100dvh - 2rem);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: var(--radius-md) !important;
  background: #FFFFFF !important;
  border: 1px solid var(--border-color) !important;
}

.modal-body {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 1.25rem !important;
}

.modal-footer {
  flex-wrap: wrap;
  gap: 0.5rem;
}

.modal-footer > * {
  min-height: 42px;
}

/* ------------------------------------------------------------
   9. Forms & Inputs Touch Friendliness
   ------------------------------------------------------------ */
.form-control,
.form-select {
  min-height: 42px;
  background-color: #FFFFFF !important;
  border-color: #DCDCDC !important;
  color: var(--text-primary) !important;
  font-size: 0.95rem;
  border-radius: var(--radius-sm);
  transition: var(--transition-fast);
}

.form-control:focus,
.form-select:focus {
  background-color: #FFFFFF !important;
  border-color: var(--primary-gold) !important;
  box-shadow: 0 0 0 3px rgba(201, 162, 39, 0.15) !important;
  color: var(--text-primary) !important;
}

.form-control-sm,
.form-select-sm {
  min-height: 38px;
  font-size: 0.88rem;
}

/* ------------------------------------------------------------
   10. Footer Responsiveness - Royal Gold Theme & Subfooter Bar
   ------------------------------------------------------------ */
.site-footer {
  background: linear-gradient(135deg, #D4AF37 0%, #C59A27 28%, #A88416 70%, #8C6509 100%) !important;
  border-top: 4px solid #DFBE58 !important;
  box-shadow: 0 -6px 25px rgba(122, 87, 6, 0.3) !important;
  padding: clamp(3rem, 2.5rem + 2vw, 5rem) 0 2rem !important;
  margin-top: auto;
  color: #FFFFFF !important;
}

.footer-divider {
  border: 0 !important;
  height: 1px !important;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent) !important;
  margin: clamp(2rem, 1.5rem + 1.5vw, 3rem) 0 1.5rem !important;
  opacity: 1 !important;
}

.footer-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  background: linear-gradient(90deg, rgba(140, 101, 9, 0.45) 0%, rgba(105, 74, 5, 0.65) 50%, rgba(140, 101, 9, 0.45) 100%) !important;
  border: 1px solid rgba(255, 255, 255, 0.28) !important;
  border-radius: 12px;
  padding: 1.15rem 1.6rem !important;
  box-shadow: inset 0 1px 3px rgba(255, 255, 255, 0.15), 0 4px 15px rgba(0, 0, 0, 0.15);
}

.footer-copyright {
  color: #FFFFFF !important;
  font-size: clamp(0.82rem, 0.78rem + 0.15vw, 0.92rem) !important;
  font-weight: 600;
  line-height: 1.5;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

@media (max-width: 767.98px) {
  .site-footer {
    padding: 2.5rem 0 1.5rem !important;
    text-align: center;
  }

  .footer-brand {
    justify-content: center;
  }

  .footer-desc {
    margin-left: auto;
    margin-right: auto;
  }

  .footer-contact-item {
    justify-content: center;
  }

  .social-links {
    justify-content: center;
  }

  .footer-bottom {
    flex-direction: column;
    text-align: center;
    gap: 0.85rem;
    padding: 1rem !important;
  }
}

/* ------------------------------------------------------------
   11. Compact Pagination on Small Devices
   ------------------------------------------------------------ */
@media (max-width: 575.98px) {
  .pagination {
    flex-wrap: wrap;
    gap: 4px;
    justify-content: center;
  }

  .pagination .page-item .page-link {
    min-width: 36px;
    height: 36px;
    padding: 0.3rem 0.5rem;
    font-size: 0.82rem;
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

/* ------------------------------------------------------------
   12. Layout Width Utilities & Ultra-Compact Adjustments
   ------------------------------------------------------------ */
.max-w-600 { max-width: 600px; width: 100%; }
.max-w-700 { max-width: 700px; width: 100%; }
.max-w-800 { max-width: 800px; width: 100%; }
.max-w-900 { max-width: 900px; width: 100%; }

/* Micro-screens (320px - 375px) safety rules */
@media (max-width: 375px) {
  html {
    font-size: 14px;
  }

  .container,
  .container-fluid {
    padding-right: 0.75rem;
    padding-left: 0.75rem;
  }

  .btn {
    font-size: 0.88rem;
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }

  .btn-sm {
    font-size: 0.8rem;
    padding: 0.25rem 0.5rem;
  }

  input[type="date"] {
    min-width: 0;
    font-size: 0.82rem;
  }

  .navbar-brand-gt .brand-title {
    font-size: 1.05rem;
  }

  .navbar-brand-gt .logo-icon {
    font-size: 1.35rem;
  }

  .kpi-card h3 {
    font-size: 1.4rem;
  }
}
