/* ==========================================================================
   Al-ghadeer Hypermarket Theme CSS
   Brand Color Palette derived strictly from official logo:
   - Primary Deep Emerald Green: #06522c
   - Secondary Leaf/Lime Green:  #5fa82a
   - Accent Sunburst Orange:     #ff9e1b & #ff6b00
   - Fresh Water/Dairy Blue:     #2fa2e3
   - Fresh White & Soft Off-white Background: #f7faf6 / #ffffff
   ========================================================================== */

:root {
  --color-primary: #06522c;
  --color-primary-dark: #04391e;
  --color-secondary: #5fa82a;
  --color-secondary-light: #eef7e8;
  --color-accent-orange: #ff9e1b;
  --color-accent-orange-dark: #e05d00;
  --color-accent-blue: #2fa2e3;
  --color-bg-light: #f7faf6;
  --color-card-bg: #ffffff;
  --color-text-main: #1c2820;
  --color-text-muted: #5c6b61;
  --color-border: #e1e9e3;
  
  --font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --shadow-subtle: 0 4px 16px rgba(6, 82, 44, 0.06);
  --shadow-hover: 0 8px 24px rgba(6, 82, 44, 0.12);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  overflow-x: hidden;
  width: 100%;
}

body {
  overflow-x: hidden;
  width: 100%;
  font-family: var(--font-family);
  background-color: var(--color-bg-light);
  color: var(--color-text-main);
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

a {
  color: inherit;
  text-decoration: none;
}

/* Header & Navigation Bar */
.site-header {
  background-color: var(--color-primary);
  color: #ffffff;
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.top-bar {
  background-color: var(--color-primary-dark);
  padding: 6px 20px;
  font-size: 0.85rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.lang-switch {
  display: flex;
  gap: 12px;
}

.lang-switch a {
  color: #ffffff;
  opacity: 0.8;
  font-weight: 500;
}

.lang-switch a.active {
  opacity: 1;
  font-weight: 700;
  border-bottom: 2px solid var(--color-accent-orange);
}

.nav-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo img {
  height: 170px;
  width: auto;
  object-fit: contain;
  background-color: #ffffff;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

.nav-links {
  display: flex;
  gap: 24px;
  list-style: none;
  font-weight: 600;
}

.nav-links a:hover {
  color: var(--color-accent-orange);
}

.search-box {
  flex: 1;
  max-width: 400px;
  position: relative;
}

.search-box input {
  width: 100%;
  padding: 10px 16px;
  border-radius: var(--radius-lg);
  border: none;
  outline: none;
  font-size: 0.95rem;
}

/* Layout Containers */
.main-container {
  max-width: 1200px;
  width: 100%;
  margin: 30px auto;
  padding: 0 20px;
  flex: 1;
}

.hero-banner {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%);
  color: #ffffff;
  border-radius: var(--radius-md);
  padding: 40px;
  margin-bottom: 40px;
  box-shadow: var(--shadow-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.hero-text h1 {
  font-size: 2.2rem;
  margin-bottom: 8px;
}

.hero-text p {
  font-size: 1.1rem;
  opacity: 0.95;
}

.badge-tag {
  background-color: var(--color-accent-orange);
  color: #ffffff;
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.85rem;
  display: inline-block;
  margin-bottom: 12px;
}

/* Catalog Grid & Cards */
.section-title {
  font-size: 1.6rem;
  color: var(--color-primary);
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-title::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 24px;
  background-color: var(--color-secondary);
  border-radius: 4px;
}

/* Universal Fluid 4-Column Product & Category Grid */
.product-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 20px;
  width: 100%;
}

/* Endless Scroll Spinner */
.endless-spinner {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  background: var(--color-card-bg);
  border: 1px solid var(--color-border);
  border-radius: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.spinner-dot {
  width: 9px;
  height: 9px;
  background-color: var(--color-primary);
  border-radius: 50%;
  display: inline-block;
  animation: endlessBounce 1.4s infinite ease-in-out both;
}

.spinner-dot:nth-child(1) {
  animation-delay: -0.32s;
}

.spinner-dot:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes endlessBounce {
  0%, 80%, 100% {
    transform: scale(0);
    opacity: 0.3;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

.product-card {
  background-color: var(--color-card-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 16px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.product-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-hover);
  border-color: var(--color-secondary);
}

.product-img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  background-color: var(--color-bg-light);
}

.product-category {
  font-size: 0.75rem;
  color: var(--color-secondary);
  font-weight: 700;
  text-transform: uppercase;
}

.product-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 4px 0 8px;
  color: var(--color-text-main);
}

.product-price {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--color-primary);
  margin-bottom: 16px;
}

.btn-primary {
  background-color: var(--color-secondary);
  color: #ffffff;
  border: none;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  cursor: pointer;
  width: 100%;
  transition: background 0.2s ease;
  text-align: center;
  display: inline-block;
}

.btn-primary:hover {
  background-color: var(--color-primary);
}

.btn-knet {
  background-color: var(--color-accent-orange);
  color: #ffffff;
  border: none;
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  font-weight: 800;
  font-size: 1.1rem;
  cursor: pointer;
  width: 100%;
  transition: background-color 0.2s ease;
  box-shadow: 0 4px 12px rgba(255, 158, 27, 0.3);
}

.btn-knet:hover {
  background-color: var(--color-accent-orange-dark);
}

/* Category Filter Pills Container */
.category-pills-container {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x;
  padding: 10px 2px 14px;
  margin-bottom: 16px;
  scrollbar-width: none;
  width: 100%;
}

.category-pills-container::-webkit-scrollbar {
  display: none;
}

.category-pill {
  flex: 0 0 auto;
  white-space: nowrap;
  padding: 8px 18px;
  background-color: var(--color-card-bg);
  border: 1px solid var(--color-border);
  border-radius: 20px;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--color-text-main);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.04);
  transition: all 0.2s ease;
}

.category-pill.active, .category-pill:hover {
  background-color: var(--color-primary);
  color: #ffffff;
  border-color: var(--color-primary);
}

/* Desktop App Bar Hide */
.mobile-app-bar {
  display: none;
}

/* Checkout Form Layout */
.checkout-wrapper {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 30px;
}

.checkout-card {
  background-color: var(--color-card-bg);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  padding: 24px;
}

.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
}

.form-group input, .form-group textarea {
  width: 100%;
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  outline: none;
  font-size: 1rem;
}

.form-group input:focus, .form-group textarea:focus {
  border-color: var(--color-primary);
}

/* Cart Added Toast Notification */
.cart-toast-notification {
  position: fixed;
  bottom: 80px;
  right: 20px;
  background-color: var(--color-primary);
  color: #ffffff;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.9rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  z-index: 3000;
  animation: fadeIn 0.2s ease;
}

[dir="rtl"] .cart-toast-notification {
  right: auto;
  left: 20px;
}
/* Scrollable Interactive Cart Item List */
.scrollable-cart-list {
  max-height: 320px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-right: 4px;
  margin-bottom: 12px;
}

[dir="rtl"] .scrollable-cart-list {
  padding-right: 0;
  padding-left: 4px;
}

.cart-item-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 8px;
  border-bottom: 1px solid var(--color-border);
  gap: 12px;
}

.cart-item-info {
  flex: 1;
}

.cart-item-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--color-text-main);
  margin-bottom: 2px;
}

.cart-item-price {
  font-size: 0.82rem;
  color: var(--color-text-muted);
}

.cart-item-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.qty-control {
  display: flex;
  align-items: center;
  background-color: var(--color-bg-light);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.qty-btn {
  background-color: #ffffff;
  border: none;
  width: 28px;
  height: 28px;
  font-weight: 800;
  font-size: 1rem;
  color: var(--color-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s ease;
}

.qty-btn:hover {
  background-color: var(--color-secondary-light);
}

.qty-val {
  padding: 0 8px;
  font-weight: 700;
  font-size: 0.9rem;
}

.cart-item-subtotal {
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--color-primary);
  min-width: 55px;
  text-align: right;
}

[dir="rtl"] .cart-item-subtotal {
  text-align: left;
}

.remove-item-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  font-weight: 800;
  color: #e53e3e;
  padding: 4px;
  opacity: 0.8;
  transition: opacity 0.2s ease, transform 0.2s ease;
  line-height: 1;
}

.remove-item-btn:hover {
  opacity: 1;
  transform: scale(1.2);
}

/* Order Summary Table */
.summary-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 0;
}

.summary-table th, .summary-table td {
  padding: 12px 8px;
  border-bottom: 1px solid var(--color-border);
  text-align: left;
}

[dir="rtl"] .summary-table th, [dir="rtl"] .summary-table td {
  text-align: right;
}

.total-row {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--color-primary);
}

/* Footer */
.site-footer {
  background-color: var(--color-primary-dark);
  color: #ffffff;
  padding: 40px 20px 20px;
  margin-top: 60px;
  text-align: center;
  font-size: 0.9rem;
}

.footer-content {
  max-width: 1200px;
  margin: 0 auto;
}

/* RTL Specific Tweaks */
[dir="rtl"] .section-title::before {
  margin-left: 10px;
}

/* Navigation Active State */
.nav-links a.active-nav {
  color: var(--color-primary);
  font-weight: 700;
  border-bottom: 2px solid var(--color-primary);
  padding-bottom: 4px;
}

/* Category Search Box & Toolbar */
.shop-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}

.category-search-box {
  position: relative;
  max-width: 340px;
  width: 100%;
}

.category-search-box input {
  width: 100%;
  padding: 10px 16px;
  border-radius: 20px;
  border: 1px solid var(--color-border);
  font-size: 0.92rem;
  background-color: var(--color-card-bg);
  outline: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03);
  transition: all 0.2s ease;
}

.category-search-box input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(6, 82, 44, 0.12);
}

/* Dynamic Responsive Category Cards Grid */
.category-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 40px;
}

.category-card {
  display: flex;
  flex-direction: column;
  background-color: var(--color-card-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease;
}

.category-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.09);
  border-color: var(--color-primary);
}

.cat-card-img-wrapper {
  position: relative;
  width: 100%;
  height: 160px;
  background-color: var(--color-bg-light);
  overflow: hidden;
}

.cat-card-img-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.35s ease;
}

.category-card:hover .cat-card-img-wrapper img {
  transform: scale(1.06);
}

.cat-count-badge {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(6, 82, 44, 0.9);
  backdrop-filter: blur(4px);
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 12px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

[dir="rtl"] .cat-count-badge {
  right: auto;
  left: 8px;
}

.cat-card-body {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  flex: 1;
  gap: 10px;
}

.cat-card-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--color-text-main);
  margin: 0;
  line-height: 1.35;
  transition: color 0.2s ease;
}

.category-card:hover .cat-card-title {
  color: var(--color-primary);
}

.cat-card-cta {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--color-primary);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* ==========================================================================
   Responsive Breakpoints
   ========================================================================== */

/* Tablet Breakpoint (768px - 1024px) */
@media (max-width: 1024px) {
  .product-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
  }
}

/* Mobile Breakpoint (<768px) */
@media (max-width: 768px) {
  body {
    padding-bottom: 70px;
  }

  .top-bar {
    padding: 6px 12px;
    font-size: 0.78rem;
  }

  .nav-container {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 12px;
  }

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

  .brand-logo img {
    height: 70px;
    max-width: 100%;
  }

  .search-box {
    max-width: 100%;
  }

  .nav-links {
    display: none; /* Mobile app bar takes over */
  }

  .main-container {
    margin: 16px auto;
    padding: 0 12px;
  }

  .hero-banner {
    padding: 20px 16px;
    margin-bottom: 20px;
    border-radius: var(--radius-sm);
  }

  .hero-text h1 {
    font-size: 1.4rem;
  }

  .hero-text p {
    font-size: 0.9rem;
  }

  /* Adaptive 2-Column Mobile Product Grid */
  .product-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  /* Adaptive 2-Column Mobile Category Cards Grid */
  .category-cards-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 24px;
  }

  .cat-card-img-wrapper {
    height: 115px;
  }

  .cat-card-body {
    padding: 10px 12px;
    gap: 6px;
  }

  .cat-card-title {
    font-size: 0.92rem;
    line-height: 1.25;
  }

  .cat-count-badge {
    font-size: 0.7rem;
    padding: 2px 7px;
  }

  .cat-card-cta {
    font-size: 0.78rem;
  }

  .product-card {
    padding: 10px;
    border-radius: var(--radius-sm);
  }

  .product-img {
    height: 130px;
    margin-bottom: 6px;
  }

  .product-title {
    font-size: 0.9rem;
    line-height: 1.25;
    margin: 2px 0 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .product-price {
    font-size: 1rem;
    margin-bottom: 8px;
  }

  .btn-primary {
    padding: 8px 10px;
    font-size: 0.85rem;
  }

  .checkout-wrapper {
    grid-template-columns: 1fr;
  }

  .checkout-card {
    padding: 16px;
  }

  /* Fixed Mobile App Bottom Bar */
  .mobile-app-bar {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background-color: #ffffff;
    border-top: 1px solid var(--color-border);
    justify-content: space-around;
    align-items: center;
    z-index: 2000;
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.08);
  }

  .app-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--color-text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    flex: 1;
    height: 100%;
  }

  .app-tab.active {
    color: var(--color-primary);
    font-weight: 800;
  }

  .app-icon {
    font-size: 1.2rem;
    line-height: 1.1;
  }

  .app-label {
    margin-top: 2px;
  }
}

/* Small Phones (<380px) */
@media (max-width: 380px) {
  .product-grid,
  .category-cards-grid {
    grid-template-columns: 1fr;
  }
}
