/* ==========================================================================
   LJOMLA (الجملة) — Mobile-First B2B Wholesale Marketplace Design System
   Tailored for Mauritania (RTL, Arabic, MRU, Mobile-First PWA)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;500;600;700;800;900&display=swap');

:root {
  /* Brand Identity - Mauritania Emerald & Amber Gold */
  --primary: #0D5C3A;
  --primary-dark: #093E27;
  --primary-light: #16794D;
  --primary-subtle: #E8F5EE;
  
  --accent: #D97706;
  --accent-light: #F59E0B;
  --accent-subtle: #FEF3C7;

  /* Neutrals */
  --bg-app: #F8FAFC;
  --bg-surface: #FFFFFF;
  --bg-surface-elevated: #FFFFFF;
  
  --text-main: #0F172A;
  --text-muted: #64748B;
  --text-inverse: #FFFFFF;
  
  --border-light: #E2E8F0;
  --border-focus: #0D5C3A;

  /* Status Colors */
  --status-pending: #F59E0B;
  --status-pending-bg: #FEF3C7;
  --status-accepted: #3B82F6;
  --status-accepted-bg: #EFF6FF;
  --status-preparing: #8B5CF6;
  --status-preparing-bg: #F5F3FF;
  --status-delivery: #0284C7;
  --status-delivery-bg: #E0F2FE;
  --status-delivered: #10B981;
  --status-delivered-bg: #D1FAE5;
  --status-cancelled: #EF4444;
  --status-cancelled-bg: #FEE2E2;

  /* Typography & Layout Metrics */
  --font-main: 'Cairo', system-ui, -apple-system, sans-serif;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  
  /* Touch target sizes (Accessible for smartphone fingers) */
  --min-tap: 48px;
  --mobile-bottom-nav-height: 64px;
  --nav-height: var(--mobile-bottom-nav-height);
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
  --content-bottom-padding: calc(var(--mobile-bottom-nav-height) + var(--safe-area-bottom) + 28px);
}

/* Base Reset & Box Sizing */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-family: var(--font-main);
  font-size: 16px;
  text-align: start;
  background-color: var(--bg-app);
  color: var(--text-main);
  scroll-behavior: smooth;
}

html[dir="rtl"] {
  direction: rtl;
  text-align: right;
}

html[dir="ltr"] {
  direction: ltr;
  text-align: left;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}


body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-app);
  padding-bottom: var(--content-bottom-padding);
}

/* Safe Area Support for iPhone notch & home indicator */
.safe-top {
  padding-top: env(safe-area-inset-top, 0px);
}
body.safe-bottom {
  padding-bottom: var(--content-bottom-padding);
}
.safe-bottom:not(body) {
  padding-bottom: var(--safe-area-bottom);
}

/* Layout Container */
.app-container {
  width: 100%;
  max-width: 680px; /* Constrained for mobile-first ergonomics */
  margin: 0 auto;
  padding: 0 16px;
}

/* Header & Top Bar */
.top-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  padding: 0 16px;
  max-width: 680px;
  margin: 0 auto;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--primary);
  font-weight: 800;
  font-size: 1.35rem;
}

.brand-icon {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Cart Icon Badge */
.header-cart-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  background: var(--bg-app);
  color: var(--text-main);
  text-decoration: none;
  font-size: 1.3rem;
  border: 1px solid var(--border-light);
}

.cart-badge {
  position: absolute;
  top: -4px;
  left: -4px;
  background: var(--accent);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 800;
  min-width: 20px;
  height: 20px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
}

/* Bottom Navigation Bar (App Bar) */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--mobile-bottom-nav-height) + var(--safe-area-bottom));
  padding-bottom: var(--safe-area-bottom);
  background: #FFFFFF;
  border-top: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 50;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.05);
}

.site-footer {
  margin-top: 40px;
  padding: 24px 0 20px 0;
  border-top: 1px solid var(--border-light);
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
}

.bidi-isolate {
  unicode-bidi: isolate;
  direction: ltr;
  display: inline-block;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.75rem;
  font-weight: 600;
  position: relative;
  transition: color 0.15s ease;
}

.nav-item.active {
  color: var(--primary);
}

.nav-icon {
  font-size: 1.3rem;
  margin-bottom: 2px;
}

.nav-badge {
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-18px);
  background: var(--accent);
  color: #fff;
  font-size: 0.7rem;
  padding: 1px 5px;
  border-radius: var(--radius-full);
  font-weight: 700;
}

/* Typography & Headings */
h1, h2, h3, h4, h5, h6 {
  color: var(--text-main);
  font-weight: 700;
  line-height: 1.3;
}

p {
  color: var(--text-muted);
  line-height: 1.5;
}

/* Cards & Surfaces */
.card {
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

.card-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Badges & Pills */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
}

.badge-verified {
  background: #E8F5EE;
  color: #0D5C3A;
  border: 1px solid #A7F3D0;
}

.badge-warning {
  background: var(--status-pending-bg);
  color: #B45309;
}

.badge-danger {
  background: var(--status-cancelled-bg);
  color: #B91C1C;
}

.badge-info {
  background: var(--status-accepted-bg);
  color: #1D4ED8;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--min-tap);
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
  width: auto;
}

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

.btn-primary:active, .btn-primary:hover {
  background: var(--primary-dark);
}

.btn-accent {
  background: var(--accent);
  color: #FFFFFF;
}

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
}

.btn-danger {
  background: #DC2626;
  color: #FFFFFF;
}

.btn-block {
  width: 100%;
}

.btn-sm {
  min-height: 36px;
  padding: 6px 12px;
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
}

/* Form Controls */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 6px;
}

.form-control, .form-select, textarea {
  width: 100%;
  min-height: var(--min-tap);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border-light);
  font-family: inherit;
  font-size: 0.95rem;
  background-color: #FFFFFF;
  color: var(--text-main);
  transition: border-color 0.15s ease;
  direction: rtl;
}

.form-control:focus, .form-select:focus, textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(13, 92, 58, 0.12);
}

/* Product Card Grid */
.product-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.product-card {
  background: #FFFFFF;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.product-card:active {
  transform: scale(0.98);
}

.product-thumb {
  width: 100%;
  height: 125px;
  background: #F1F5F9;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.product-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.product-thumb-fallback {
  font-size: 2.5rem;
}

.product-body {
  padding: 10px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.product-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  height: 2.8em;
}

.product-supplier {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 6px;
}

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

.product-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: auto;
  padding-top: 6px;
  border-top: 1px dashed var(--border-light);
}

.moq-tag {
  color: var(--accent);
  font-weight: 700;
}

/* Category Slider */
.category-slider {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 8px 0 16px 0;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.category-slider::-webkit-scrollbar {
  display: none;
}

.category-chip {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-full);
  background: #FFFFFF;
  border: 1px solid var(--border-light);
  text-decoration: none;
  color: var(--text-main);
  font-size: 0.85rem;
  font-weight: 600;
  transition: all 0.15s ease;
}

.category-chip.active {
  background: var(--primary);
  color: #FFFFFF;
  border-color: var(--primary);
}

/* Search Bar */
.search-box {
  position: relative;
  margin: 12px 0 16px 0;
}

.search-input {
  width: 100%;
  height: 48px;
  border-radius: var(--radius-full);
  padding: 0 44px 0 16px;
  border: 1px solid var(--border-light);
  background: #FFFFFF;
  font-family: inherit;
  font-size: 0.95rem;
  box-shadow: var(--shadow-sm);
}

.search-btn {
  position: absolute;
  top: 50%;
  right: 12px;
  transform: translateY(-50%);
  background: none;
  border: none;
  font-size: 1.2rem;
  color: var(--text-muted);
  cursor: pointer;
}

/* Flash Messages */
.alert-container {
  margin: 12px 0;
}

.alert-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  margin-bottom: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  animation: fadeIn 0.2s ease;
}

.alert-success {
  background: #ECFDF5;
  color: #065F46;
  border: 1px solid #A7F3D0;
}

.alert-danger {
  background: #FEF2F2;
  color: #991B1B;
  border: 1px solid #FECACA;
}

.alert-warning {
  background: #FFFBEB;
  color: #92400E;
  border: 1px solid #FDE68A;
}

.alert-info {
  background: #EFF6FF;
  color: #1E40AF;
  border: 1px solid #BFDBFE;
}

.alert-close-btn {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: inherit;
  opacity: 0.7;
}

/* Order Status Timeline */
.timeline {
  list-style: none;
  position: relative;
  padding: 16px 0;
  margin: 16px 0;
}

.timeline::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  right: 18px;
  width: 3px;
  background: var(--border-light);
}

.timeline-item {
  position: relative;
  padding-right: 48px;
  margin-bottom: 20px;
}

.timeline-dot {
  position: absolute;
  top: 0;
  right: 9px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #CBD5E1;
  border: 3px solid #FFFFFF;
  box-shadow: var(--shadow-sm);
}

.timeline-item.active .timeline-dot {
  background: var(--primary);
  box-shadow: 0 0 0 3px rgba(13, 92, 58, 0.2);
}

.timeline-item.completed .timeline-dot {
  background: var(--status-delivered);
}

.timeline-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-main);
}

.timeline-time {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Utilities */
.d-none { display: none !important; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-primary { color: var(--primary); }
.text-accent { color: var(--accent); }
.font-bold { font-weight: 700; }

/* Language Switcher Component */
.lang-switcher {
  display: inline-flex;
  align-items: center;
  background: rgba(13, 92, 58, 0.08);
  border: 1px solid rgba(13, 92, 58, 0.2);
  border-radius: var(--radius-full);
  padding: 3px 6px;
  gap: 4px;
  font-size: 0.8rem;
  font-weight: 700;
}

.lang-btn {
  padding: 3px 8px;
  border-radius: var(--radius-full);
  color: var(--text-muted);
  text-decoration: none;
  transition: all 0.15s ease;
  white-space: nowrap;
}

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

.lang-btn.active {
  background: var(--primary);
  color: #FFFFFF;
  box-shadow: var(--shadow-sm);
}

/* LTR Adjustments */
html[dir="ltr"] .cart-badge {
  left: auto;
  right: -4px;
}

html[dir="ltr"] .timeline-item {
  border-right: none;
  border-left: 2px solid var(--border-light);
  padding-right: 0;
  padding-left: 20px;
}

html[dir="ltr"] .timeline-dot {
  right: auto;
  left: 9px;
}

html[dir="ltr"] .form-check-input {
  margin-right: 8px;
  margin-left: 0;
}

.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.p-3 { padding: 12px; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
