/* ==========================================================================
   Algcool Market - Luxury Dual Theme System (Dark Obsidian & Pure Light)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;500;600;700;800;900&family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=Space+Grotesk:wght@500;600;700&display=swap');

:root {
  /* Default Dark Mode (Obsidian Emerald & Gold Glow) */
  --bg-main: #070c0a;
  --bg-card: rgba(13, 24, 20, 0.85);
  --bg-card-hover: rgba(20, 36, 30, 0.95);
  --bg-surface: #0e1713;
  --bg-surface-secondary: #09130f;
  --bg-glass: rgba(14, 25, 21, 0.75);
  --bg-glass-heavy: rgba(8, 15, 12, 0.95);
  
  --emerald-neon: #00e599;
  --emerald-glow: rgba(0, 229, 153, 0.35);
  --emerald-deep: #033827;
  --emerald-border: rgba(0, 229, 153, 0.25);
  --emerald-border-hover: rgba(0, 229, 153, 0.6);

  --gold-amber: #f59e0b;
  --gold-light: #fde68a;
  --gold-glow: rgba(245, 158, 11, 0.35);
  --gold-gradient: linear-gradient(135deg, #fbbf24 0%, #d97706 100%);
  --emerald-gradient: linear-gradient(135deg, #00e599 0%, #059669 100%);

  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --text-subtle: #6b7280;
  --text-inverse: #05140e;

  --success: #10b981;
  --danger: #ef4444;
  --info: #3b82f6;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;
  
  --shadow-subtle: 0 4px 20px rgba(0, 0, 0, 0.5);
  --shadow-neon: 0 8px 30px rgba(0, 229, 153, 0.2);
  --shadow-gold: 0 8px 30px rgba(245, 158, 11, 0.2);
  --border-glass: 1px solid rgba(255, 255, 255, 0.1);
}

/* Light Theme Variables */
[data-theme="light"] {
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --bg-surface: #ffffff;
  --bg-surface-secondary: #e2e8f0;
  --bg-glass: rgba(255, 255, 255, 0.9);
  --bg-glass-heavy: rgba(255, 255, 255, 0.98);
  
  --emerald-neon: #059669;
  --emerald-glow: rgba(5, 150, 105, 0.25);
  --emerald-deep: #064e3b;
  --emerald-border: rgba(5, 150, 105, 0.3);
  --emerald-border-hover: rgba(5, 150, 105, 0.6);

  --gold-amber: #d97706;
  --gold-light: #b45309;
  --gold-glow: rgba(217, 119, 6, 0.25);
  --gold-gradient: linear-gradient(135deg, #f59e0b 0%, #b45309 100%);
  --emerald-gradient: linear-gradient(135deg, #10b981 0%, #047857 100%);

  --text-main: #0f172a;
  --text-muted: #475569;
  --text-subtle: #64748b;
  --text-inverse: #ffffff;

  --shadow-subtle: 0 4px 20px rgba(0, 0, 0, 0.08);
  --shadow-neon: 0 8px 30px rgba(5, 150, 105, 0.15);
  --shadow-gold: 0 8px 30px rgba(217, 119, 6, 0.15);
  --border-glass: 1px solid rgba(0, 0, 0, 0.12);
}

/* Base Styles & Resets */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  font-size: 15px;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

body {
  font-family: 'DM Sans', 'Cairo', sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
  max-width: 100%;
  overflow-x: hidden;
  position: relative;
  transition: background-color 0.3s ease, color 0.3s ease;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: 0;
}

body.has-bottom-nav {
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}

[data-theme="dark"] body {
  background-image: 
    radial-gradient(circle at 15% 15%, rgba(0, 229, 153, 0.06) 0%, transparent 45%),
    radial-gradient(circle at 85% 75%, rgba(245, 158, 11, 0.04) 0%, transparent 50%);
  background-attachment: fixed;
}

body[dir="rtl"] {
  font-family: 'Cairo', 'DM Sans', sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
  transition: all 0.2s ease;
  touch-action: manipulation;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  outline: none;
  touch-action: manipulation;
}

.container {
  width: min(1280px, calc(100% - 32px));
  margin: 0 auto;
}

/* Typography Helpers */
h1, h2, h3, h4, .font-heading {
  font-family: 'Space Grotesk', 'Cairo', sans-serif;
  font-weight: 700;
  line-height: 1.25;
}

body[dir="rtl"] h1, body[dir="rtl"] h2, body[dir="rtl"] h3 {
  font-family: 'Cairo', sans-serif;
}

.text-gradient-emerald {
  background: linear-gradient(135deg, var(--text-main) 30%, var(--emerald-neon) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.text-gradient-gold {
  background: linear-gradient(135deg, var(--text-main) 30%, var(--gold-amber) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* ==========================================================================
   Header & Announcement Top Bar
   ========================================================================== */
.announcement {
  background: var(--bg-surface-secondary);
  border-bottom: 1px solid var(--border-glass);
  font-size: 0.85rem;
  padding: 8px 0;
  position: relative;
  z-index: 101;
}

.announcement-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 15px;
}

.announcement-ticker {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--emerald-neon);
  font-weight: 600;
}

.badge-live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 229, 153, 0.15);
  color: var(--emerald-neon);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-weight: 700;
  font-size: 0.75rem;
  border: 1px solid var(--emerald-border);
}

.badge-live::before {
  content: '';
  width: 6px;
  height: 6px;
  background: var(--emerald-neon);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--emerald-neon);
  animation: pulse-dot 1.5s infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}

.top-bar-tools {
  display: flex;
  align-items: center;
  gap: 10px;
}

.theme-toggle-btn, .lang-switch-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-card);
  border: var(--border-glass);
  padding: 5px 12px;
  border-radius: var(--radius-full);
  color: var(--text-main);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.theme-toggle-btn:hover, .lang-switch-btn:hover {
  border-color: var(--emerald-neon);
  color: var(--emerald-neon);
}

/* Site Main Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-glass-heavy);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-glass);
  transition: all 0.3s ease;
}

.header-main {
  height: 80px;
  display: flex;
  direction: ltr;
  align-items: center;
  justify-content: space-between;
  gap: 25px;
}

.brand {
  display: flex;
  direction: rtl;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.brand-emblem {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  object-fit: cover;
  border: 1px solid var(--emerald-border);
  box-shadow: 0 0 15px var(--emerald-glow);
  transition: transform 0.3s ease;
}

.brand:hover .brand-emblem {
  transform: scale(1.05) rotate(2deg);
  border-color: var(--emerald-neon);
}

.brand-info {
  display: flex;
  flex-direction: column;
  direction: rtl;
}

.brand-name {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 800;
  font-size: 1.55rem;
  letter-spacing: -0.5px;
  color: var(--text-main);
  display: flex;
  direction: ltr;
  unicode-bidi: isolate;
  align-items: center;
  gap: 2px;
}

.brand-name span {
  color: var(--emerald-neon);
  text-shadow: 0 0 12px var(--emerald-glow);
}

.brand-tagline {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Search Bar */
.search-bar {
  flex: 1;
  max-width: 500px;
  position: relative;
  display: flex;
  align-items: center;
  direction: rtl;
}

.search-bar input {
  width: 100%;
  height: 46px;
  background: var(--bg-surface);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-full);
  padding: 0 20px 0 46px;
  color: var(--text-main);
  font-size: 0.92rem;
  transition: all 0.25s ease;
}

body[dir="rtl"] .search-bar input {
  padding: 0 46px 0 20px;
}

.search-bar input:focus {
  border-color: var(--emerald-neon);
  box-shadow: 0 0 20px var(--emerald-glow);
}

.search-icon {
  position: absolute;
  left: 16px;
  color: var(--text-muted);
  pointer-events: none;
  font-size: 1.1rem;
}

.search-bar .search-icon[role="button"] {
  pointer-events: auto;
  cursor: pointer;
}

body[dir="rtl"] .search-icon {
  left: auto;
  right: 16px;
}

/* Header Actions */
.header-actions {
  display: flex;
  direction: rtl;
  align-items: center;
  gap: 12px;
}

.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-full);
  font-size: 0.88rem;
  font-weight: 600;
  border: var(--border-glass);
  background: var(--bg-card);
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.2s ease;
}

.action-btn:hover {
  border-color: var(--emerald-neon);
  transform: translateY(-1px);
}

.profile-btn {
  border-color: var(--emerald-border);
  background: var(--bg-surface);
  color: var(--text-main);
}

.profile-btn:hover {
  border-color: var(--emerald-neon);
  box-shadow: 0 0 15px var(--emerald-glow);
}

/* في نسخة الحاسوب، زر "الملف الشخصي" يظهر في الصفحة الرئيسية فقط.
   على الجوال يبقى كما هو (الوصول للحساب متاح أيضاً عبر الشريط السفلي). */
@media (min-width: 769px) {
  .page-produit .header-actions .profile-btn,
  .page-produits .header-actions .profile-btn {
    display: none !important;
  }
}

.profile-avatar-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--emerald-gradient);
  color: #fff;
  display: inline-grid;
  place-items: center;
  font-size: 0.75rem;
  font-weight: 800;
}

.cart-btn {
  background: var(--emerald-gradient);
  color: #fff;
  border: none;
}

.cart-badge {
  background: var(--gold-amber);
  color: #000;
  font-size: 0.75rem;
  font-weight: 800;
  padding: 1px 7px;
  border-radius: var(--radius-full);
}

/* Welcome & Profile & Orders Modal Styles */
.welcome-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 10001;
  display: none;
  place-items: center;
  padding: 20px;
}
.welcome-modal-overlay.active { display: grid; }
.welcome-modal-card {
  background: var(--bg-card);
  border: 1px solid var(--emerald-border);
  border-radius: var(--radius-lg);
  padding: 30px;
  width: min(520px, 100%);
  box-shadow: var(--shadow-subtle), 0 0 45px var(--emerald-glow);
  position: relative;
  animation: modalPop 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  max-height: 90vh;
  overflow-y: auto;
}
.my-order-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 12px;
  text-align: right;
  transition: all 0.2s ease;
}
.my-order-card:hover {
  border-color: var(--emerald-border);
}
@keyframes modalPop {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}

/* Category Navigation Subheader */
.category-nav {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-glass);
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
}

.category-nav::-webkit-scrollbar {
  display: none;
}

.category-nav-inner {
  display: grid;
  grid-template-columns: repeat(9, max-content);
  gap: 6px;
  padding: 10px 0;
}

.category-nav-break {
  display: none;
}

.cat-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: var(--radius-full);
  font-size: 0.84rem;
  color: var(--text-muted);
  font-weight: 500;
  transition: all 0.2s ease;
  border: 1px solid transparent;
}

.cat-link:hover, .cat-link.active {
  color: var(--text-main);
  background: var(--bg-card);
  border-color: var(--border-glass);
}

.cat-link.highlight {
  color: var(--gold-amber);
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.3);
}

.cat-link.all-products-btn {
  background: var(--emerald-gradient);
  color: #032115 !important;
  font-weight: 800 !important;
  border: 1px solid var(--emerald-neon);
  box-shadow: 0 0 18px var(--emerald-glow);
  padding: 7px 18px;
  font-size: 0.88rem;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: var(--radius-full);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.home-cat-pills {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 10px 0 20px;
  scrollbar-width: none;
  flex-wrap: wrap;
}
.home-cat-pills::-webkit-scrollbar { display: none; }
.cat-pill {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  color: var(--text-muted);
  padding: 8px 16px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.25s ease;
  font-family: inherit;
}
.cat-pill:hover {
  border-color: var(--emerald-border);
  color: var(--text-main);
  transform: translateY(-1px);
}
.cat-pill.active {
  background: var(--emerald-gradient);
  color: #032115;
  border-color: var(--emerald-neon);
  box-shadow: 0 0 16px var(--emerald-glow);
}

.header-all-products-btn {
  background: rgba(0, 229, 153, 0.15) !important;
  border: 1px solid var(--emerald-border) !important;
  color: var(--emerald-neon) !important;
  font-weight: 800 !important;
  box-shadow: 0 0 15px rgba(0, 229, 153, 0.15);
}

.header-all-products-btn:hover {
  background: var(--emerald-gradient) !important;
  color: #032115 !important;
  box-shadow: 0 0 25px var(--emerald-glow) !important;
  transform: translateY(-2px);
}

/* Hero Section */
.hero-section {
  padding: 50px 0 40px;
  position: relative;
}

.hero-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 40px;
  align-items: center;
}

.hero-content {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.hero-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 229, 153, 0.1);
  border: 1px solid var(--emerald-border);
  padding: 6px 16px;
  border-radius: var(--radius-full);
  color: var(--emerald-neon);
  font-size: 0.82rem;
  font-weight: 700;
  width: fit-content;
  box-shadow: 0 0 15px var(--emerald-glow);
}

.hero-title {
  font-size: clamp(2.3rem, 4.5vw, 3.5rem);
  font-weight: 800;
  letter-spacing: -1px;
  line-height: 1.15;
  color: var(--text-main);
}

.hero-description {
  font-size: 1.12rem;
  color: var(--text-muted);
  max-width: 580px;
  line-height: 1.65;
}

.hero-actions {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-items: center;
}

.btn-primary-luxury {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--emerald-gradient);
  color: #fff;
  font-weight: 800;
  font-size: 1.05rem;
  padding: 14px 28px;
  border-radius: var(--radius-full);
  border: none;
  cursor: pointer;
  box-shadow: 0 10px 30px var(--emerald-glow);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-primary-luxury:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 40px var(--emerald-glow);
}

.btn-secondary-luxury {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--bg-card);
  border: var(--border-glass);
  color: var(--text-main);
  font-weight: 600;
  font-size: 1rem;
  padding: 14px 26px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-secondary-luxury:hover {
  border-color: var(--emerald-neon);
  transform: translateY(-2px);
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  padding-top: 15px;
  border-top: 1px solid var(--border-glass);
}

.stat-item strong {
  display: block;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.35rem;
  color: var(--emerald-neon);
  font-weight: 800;
}

.stat-item span {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
}

.hero-visual-wrap {
  position: relative;
}

.hero-3d-card {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--emerald-border);
  box-shadow: var(--shadow-neon), var(--shadow-subtle);
  background: var(--bg-surface);
}

.hero-3d-img {
  width: 100%;
  height: auto;
  object-fit: cover;
  display: block;
}

.floating-glass-badge {
  position: absolute;
  background: var(--bg-glass-heavy);
  backdrop-filter: blur(16px);
  border: 1px solid var(--emerald-border);
  padding: 10px 16px;
  border-radius: var(--radius-md);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: float 4s ease-in-out infinite;
}

.floating-badge-top { top: 18px; right: 18px; }
body[dir="rtl"] .floating-badge-top { right: auto; left: 18px; }
.floating-badge-bottom { bottom: 18px; left: 18px; animation-delay: 2s; }
body[dir="rtl"] .floating-badge-bottom { left: auto; right: 18px; }

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.badge-icon-gold {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(245, 158, 11, 0.2);
  color: var(--gold-amber);
  display: grid;
  place-items: center;
  font-size: 1.1rem;
}

.badge-icon-emerald {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(0, 229, 153, 0.2);
  color: var(--emerald-neon);
  display: grid;
  place-items: center;
  font-size: 1.1rem;
}

/* Trust Strip */
.trust-section { padding: 20px 0 40px; }
.trust-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.trust-box {
  background: var(--bg-card);
  border: var(--border-glass);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: all 0.25s ease;
}
.trust-box:hover {
  background: var(--bg-card-hover);
  border-color: var(--emerald-border);
  transform: translateY(-2px);
}
.trust-icon-wrap {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(0, 229, 153, 0.1);
  color: var(--emerald-neon);
  display: grid;
  place-items: center;
  font-size: 1.3rem;
  flex-shrink: 0;
  border: 1px solid var(--emerald-border);
}
.trust-text h4 { font-size: 0.92rem; font-weight: 700; color: var(--text-main); }
.trust-text p { font-size: 0.78rem; color: var(--text-muted); }

/* 58 Wilayas Calculator */
.calculator-section { padding: 40px 0 50px; }
.calculator-card {
  background: var(--bg-card);
  border: 1px solid var(--emerald-border);
  border-radius: var(--radius-lg);
  padding: 36px;
  box-shadow: var(--shadow-subtle), 0 0 35px var(--emerald-glow);
  position: relative;
  overflow: hidden;
}
.calculator-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 3px;
  background: var(--emerald-gradient);
}
.calc-header { text-align: center; max-width: 650px; margin: 0 auto 30px; }
.calc-header h2 { font-size: 1.8rem; margin-bottom: 8px; color: var(--text-main); }
.calc-header p { color: var(--text-muted); font-size: 0.95rem; }
.calc-grid { display: grid; grid-template-columns: 1.2fr 0.8fr; gap: 30px; align-items: center; }
.calc-inputs { display: flex; flex-direction: column; gap: 18px; }
.input-group { display: flex; flex-direction: column; gap: 6px; }
.input-group label { font-size: 0.85rem; font-weight: 600; color: var(--text-main); }
.custom-select {
  width: 100%;
  height: 50px;
  background: var(--bg-surface);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  padding: 0 16px;
  color: var(--text-main);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}
.custom-select:focus {
  border-color: var(--emerald-neon);
  box-shadow: 0 0 15px var(--emerald-glow);
}
.calc-result-box {
  background: var(--bg-surface);
  border: 1px solid var(--emerald-border);
  border-radius: var(--radius-md);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-glass);
}
.result-row:last-child { border-bottom: none; padding-bottom: 0; }
.result-label { color: var(--text-muted); font-size: 0.9rem; }
.result-value {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--emerald-neon);
  font-family: 'Space Grotesk', sans-serif;
}
.time-badge {
  background: rgba(245, 158, 11, 0.15);
  color: var(--gold-amber);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-weight: 700;
  font-size: 0.85rem;
}

/* Flash Deals */
.flash-section { padding: 40px 0; }
.flash-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 15px;
}
.timer-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  color: var(--danger);
  font-weight: 700;
  font-size: 0.88rem;
}
.timer-digits { font-family: 'Space Grotesk', monospace; font-weight: 800; }
.flagship-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 22px;
}
.product-card {
  background: var(--bg-card);
  border: var(--border-glass);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  position: relative;
}
.product-card:hover {
  transform: translateY(-5px);
  border-color: var(--emerald-border-hover);
  box-shadow: 0 12px 35px var(--emerald-glow);
  background: var(--bg-card-hover);
}
.card-badge {
  position: absolute;
  top: 12px; left: 12px;
  background: var(--gold-gradient);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 800;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  z-index: 2;
}
body[dir="rtl"] .card-badge { left: auto; right: 12px; }
.card-img-wrap { width: 100%; aspect-ratio: 1 / 1; overflow: hidden; background: #000; position: relative; }
.card-img-wrap img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.4s ease; }
.product-card:hover .card-img-wrap img { transform: scale(1.06); }
.card-body { padding: 18px; display: flex; flex-direction: column; flex: 1; }
.card-cat { font-size: 0.75rem; color: var(--emerald-neon); font-weight: 700; text-transform: uppercase; margin-bottom: 4px; }
.card-title { font-size: 1rem; font-weight: 700; margin-bottom: 10px; color: var(--text-main); line-height: 1.35; }
.card-price-row { display: flex; align-items: baseline; gap: 8px; margin-top: auto; margin-bottom: 14px; }
.price-dzd { font-size: 1.25rem; font-weight: 800; color: var(--text-main); font-family: 'Space Grotesk', sans-serif; }
.price-old { font-size: 0.85rem; color: var(--text-subtle); text-decoration: line-through; }
.price-usd { font-size: 0.75rem; color: var(--text-muted); }
.card-btn-group { display: grid; grid-template-columns: 1fr 1.2fr; gap: 8px; }
.btn-card-details {
  padding: 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: var(--border-glass);
  color: var(--text-main);
  font-size: 0.82rem;
  font-weight: 600;
  text-align: center;
}
.btn-card-express {
  padding: 8px;
  border-radius: var(--radius-sm);
  background: var(--emerald-gradient);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 800;
  border: none;
  cursor: pointer;
  text-align: center;
}

/* Reviews */
.reviews-section { padding: 50px 0; }
.reviews-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; }
.review-card {
  background: var(--bg-card);
  border: var(--border-glass);
  border-radius: var(--radius-md);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.review-header { display: flex; justify-content: space-between; align-items: center; }
.reviewer-info strong { display: block; font-size: 0.95rem; color: var(--text-main); }
.reviewer-info small { color: var(--text-muted); font-size: 0.78rem; }
.stars { color: var(--gold-amber); font-size: 0.9rem; }
.review-text { font-size: 0.9rem; color: var(--text-muted); line-height: 1.5; }
.review-badge { display: inline-flex; align-items: center; gap: 5px; font-size: 0.72rem; color: var(--emerald-neon); font-weight: 600; }

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(14px);
  z-index: 1000;
  display: none;
  place-items: center;
  padding: 20px;
}
.modal-overlay.active { display: grid; }
.modal-container {
  background: var(--bg-card);
  border: 1px solid var(--emerald-border);
  border-radius: var(--radius-lg);
  width: min(520px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
  position: relative;
}
.modal-head {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-glass);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-head h3 { font-size: 1.25rem; color: var(--text-main); }
.modal-close { background: none; border: none; color: var(--text-muted); font-size: 1.5rem; cursor: pointer; }
.modal-body { padding: 24px; display: flex; flex-direction: column; gap: 18px; }
.modal-prod-summary {
  display: flex;
  gap: 14px;
  background: var(--bg-surface);
  border: var(--border-glass);
  padding: 12px;
  border-radius: var(--radius-sm);
  align-items: center;
}
.modal-prod-img { width: 60px; height: 60px; border-radius: 8px; object-fit: cover; }
.modal-prod-info strong { display: block; font-size: 0.95rem; color: var(--text-main); }
.modal-prod-info span { font-size: 0.85rem; color: var(--emerald-neon); font-weight: 700; }
.modal-field { display: flex; flex-direction: column; gap: 6px; }
.modal-field label { font-size: 0.82rem; font-weight: 600; color: var(--text-main); }
.modal-field input, .modal-field select, .modal-field textarea {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  color: var(--text-main);
  font-size: 0.9rem;
}
.modal-field input:focus, .modal-field select:focus, .modal-field textarea:focus {
  border-color: var(--emerald-neon);
  box-shadow: 0 0 12px var(--emerald-glow);
}
.modal-total-bar {
  background: rgba(0, 229, 153, 0.08);
  border: 1px solid var(--emerald-border);
  padding: 14px;
  border-radius: var(--radius-sm);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-total-bar strong { font-size: 1.25rem; color: var(--emerald-neon); }
.btn-confirm-order {
  width: 100%;
  padding: 14px;
  background: var(--emerald-gradient);
  color: #fff;
  font-size: 1.05rem;
  font-weight: 800;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  box-shadow: 0 8px 25px var(--emerald-glow);
}

/* Chat Widget */
.chat-widget-btn {
  position: fixed;
  bottom: 24px; right: 24px;
  width: 60px; height: 60px;
  border-radius: 50%;
  background: var(--emerald-gradient);
  color: #fff;
  border: none;
  display: grid;
  place-items: center;
  font-size: 1.6rem;
  cursor: pointer;
  z-index: 999;
  box-shadow: 0 8px 30px var(--emerald-glow);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
body[dir="rtl"] .chat-widget-btn { right: auto; left: 24px; }
.chat-widget-btn:hover { transform: scale(1.08); }
.chat-ping {
  position: absolute;
  top: 0; right: 0;
  width: 14px; height: 14px;
  background: var(--gold-amber);
  border: 2px solid var(--bg-main);
  border-radius: 50%;
}
.chat-window {
  position: fixed;
  bottom: 96px; right: 24px;
  width: min(380px, calc(100vw - 48px));
  height: 480px;
  background: var(--bg-card);
  border: 1px solid var(--emerald-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3), 0 0 30px var(--emerald-glow);
  z-index: 999;
  display: none;
  flex-direction: column;
  overflow: hidden;
}
body[dir="rtl"] .chat-window { right: auto; left: 24px; }
.chat-window.active { display: flex; }
.chat-head {
  background: var(--bg-surface-secondary);
  border-bottom: 1px solid var(--border-glass);
  padding: 14px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.chat-rep-info { display: flex; align-items: center; gap: 10px; }
.chat-rep-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--emerald-neon);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
}
.chat-rep-text strong { display: block; font-size: 0.9rem; color: var(--text-main); }
.chat-rep-text small { font-size: 0.72rem; color: var(--emerald-neon); display: flex; align-items: center; gap: 4px; }
.chat-rep-text small::before { content: ''; width: 6px; height: 6px; background: var(--emerald-neon); border-radius: 50%; }
.chat-messages {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--bg-surface);
}
.chat-msg {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.88rem;
  line-height: 1.4;
}
.chat-msg-bot {
  background: var(--bg-card);
  color: var(--text-main);
  border: var(--border-glass);
  align-self: flex-start;
}
.chat-msg-admin {
  background: linear-gradient(135deg, rgba(255, 183, 3, 0.18), rgba(255, 183, 3, 0.06));
  color: var(--text-main);
  border: 1px solid var(--gold-amber);
  align-self: flex-start;
  padding-top: 20px;
  position: relative;
  box-shadow: 0 4px 14px rgba(255, 183, 3, 0.12);
}
.chat-msg-admin::before {
  content: "🛡️ مشرف Algcool";
  position: absolute;
  top: 5px;
  right: 14px;
  font-size: 10px;
  font-weight: 800;
  color: var(--gold-amber);
  letter-spacing: 0.2px;
}
.chat-msg-system {
  align-self: center;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.76rem;
  text-align: center;
  padding: 4px 10px;
}
.chat-msg-user {
  background: var(--emerald-gradient);
  color: #fff;
  font-weight: 600;
  align-self: flex-end;
}
.chat-input-bar {
  padding: 12px;
  background: var(--bg-surface-secondary);
  border-top: 1px solid var(--border-glass);
  display: flex;
  gap: 8px;
}
.chat-image-btn {
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  border: 1px solid var(--border-glass);
  border-radius: 50%;
  background: var(--bg-card);
  color: var(--text-main);
  cursor: pointer;
  font-size: 1.45rem;
  line-height: 1;
  font-weight: 700;
}
.chat-input-bar input {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-full);
  padding: 8px 16px;
  color: var(--text-main);
  font-size: 0.85rem;
}
.chat-image-preview {
  position: relative;
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 0 12px 10px;
  background: var(--bg-surface-secondary);
}
.chat-image-preview img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border-glass);
}
.chat-image-preview button {
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 50%;
  background: var(--bg-card);
  color: var(--text-main);
  cursor: pointer;
}
.chat-input-error {
  min-height: 0;
  padding: 0 12px 8px;
  background: var(--bg-surface-secondary);
  color: #fca5a5;
  font-size: 0.75rem;
}
.chat-message-image {
  display: block;
  max-width: 220px;
  max-height: 220px;
  margin-top: 6px;
  border-radius: 8px;
  object-fit: contain;
}
.chat-send-btn {
  background: var(--emerald-neon);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 38px; height: 38px;
  display: grid;
  place-items: center;
  cursor: pointer;
  font-weight: 800;
}
.checkout-payment {
  display: grid;
  gap: 10px;
  margin: 14px 0;
  padding: 12px;
  border: 1px solid var(--border-glass);
  border-radius: 8px;
}
.payment-method-option {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.payment-method-option img {
  width: 88px;
  height: 30px;
  object-fit: contain;
  border-radius: 6px;
}
.product-payment-instructions {
  white-space: pre-wrap;
  margin: 8px 0;
  padding: 12px;
  border: 1px solid var(--emerald-border);
  border-radius: 8px;
  background: var(--bg-surface);
  color: var(--text-main);
  font-size: 13px;
  line-height: 1.6;
}

/* Sales Toast */
.sales-toast {
  position: fixed;
  bottom: 24px; left: 24px;
  background: var(--bg-card);
  border: 1px solid var(--emerald-border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  display: none;
  align-items: center;
  gap: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  z-index: 998;
  max-width: 340px;
}
body[dir="rtl"] .sales-toast { left: auto; right: 24px; }
.sales-toast.active { display: flex; }
.sales-toast-icon {
  width: 36px; height: 36px;
  border-radius: 8px;
  background: rgba(0, 229, 153, 0.15);
  color: var(--emerald-neon);
  display: grid;
  place-items: center;
  font-size: 1.1rem;
}
.sales-toast-info strong { display: block; font-size: 0.85rem; color: var(--text-main); }
.sales-toast-info small { font-size: 0.72rem; color: var(--text-muted); }

/* Footer */
.site-footer {
  background: var(--bg-surface-secondary);
  border-top: 1px solid var(--border-glass);
  padding: 60px 0 30px;
  margin-top: 60px;
}
.footer-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr 1fr;
  gap: 40px;
  margin-bottom: 40px;
}
.footer-brand-col p { color: var(--text-muted); font-size: 0.88rem; margin: 14px 0; max-width: 300px; }
.footer-links h4 { font-size: 0.95rem; color: var(--text-main); margin-bottom: 16px; }
.footer-links ul { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.footer-links a { color: var(--text-muted); font-size: 0.85rem; }
.footer-links a:hover { color: var(--emerald-neon); }
.footer-bottom {
  padding-top: 24px;
  border-top: 1px solid var(--border-glass);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: var(--text-subtle);
}

/* ==========================================================================
   Admin Master Unified Dashboard Styles
   ========================================================================== */
.admin-master-page {
  background: var(--bg-main);
  min-height: 100vh;
  padding: 30px 0 60px;
  color: var(--text-main);
}
.admin-course-row {
  display: grid;
  grid-template-columns: 58px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-glass);
}
.admin-course-icon {
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  overflow: hidden;
  background: var(--emerald-gradient);
  border-radius: 10px;
  font-size: 25px;
}
.admin-course-icon img { width: 100%; height: 100%; object-fit: cover; }
.admin-course-info { min-width: 0; }
.admin-course-info strong { display: block; color: var(--text-main); font-size: 13px; }
.admin-course-info small, .admin-course-info p { display: block; margin: 4px 0 0; color: var(--text-muted); font-size: 11px; }
.admin-course-info p { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-course-actions { display: flex; gap: 6px; }
.admin-course-actions button { padding: 7px 9px; color: var(--text-main); background: var(--bg-surface); border: 1px solid var(--border-glass); border-radius: 6px; cursor: pointer; font-size: 11px; }
.admin-course-actions button:last-child { color: #fca5a5; }
.admin-course-empty { padding: 32px; color: var(--text-muted); text-align: center; }
.admin-analysis-panel {
  margin: 24px 0;
  padding: 22px;
  background: var(--bg-card);
  border: 1px solid var(--emerald-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-subtle);
}
.admin-analysis-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}
.admin-analysis-head h2 {
  margin-top: 8px;
  color: var(--text-main);
  font-size: 20px;
}
.admin-analysis-head > span:last-child {
  color: var(--text-muted);
  font-size: 12px;
}
.admin-analysis-head select {
  padding: 8px 12px;
  color: var(--text-main);
  background: var(--bg-surface);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
}
.sales-analysis-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-bottom: 22px;
}
.sales-analysis-card {
  padding: 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
}
.sales-analysis-card span,
.sales-analysis-card small {
  display: block;
  color: var(--text-muted);
  font-size: 12px;
}
.sales-analysis-card strong {
  display: block;
  margin: 8px 0 4px;
  color: var(--emerald-neon);
  font-size: 22px;
}
.sales-analysis-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
}
.sales-analysis-columns h3 {
  margin-bottom: 12px;
  color: var(--text-main);
  font-size: 14px;
}
.analysis-status-row,
.analysis-product-row {
  margin-bottom: 12px;
}
.analysis-status-row > div:first-child,
.analysis-product-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
}
.analysis-status-row strong,
.analysis-product-row b {
  color: var(--emerald-neon);
}
.analysis-bar {
  height: 6px;
  margin-top: 6px;
  overflow: hidden;
  background: var(--border-glass);
  border-radius: 99px;
}
.analysis-bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
}
.analysis-product-row > div {
  flex: 1;
  min-width: 0;
}
.analysis-product-row strong {
  display: block;
  overflow: hidden;
  color: var(--text-main);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.analysis-product-rank {
  display: grid;
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  place-items: center;
  color: #032115;
  background: var(--emerald-neon);
  border-radius: 50%;
  font-weight: 800;
}
.advanced-analysis-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 14px;
  margin-top: 18px;
}
.advanced-analysis-card {
  padding: 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
}
.advanced-table-card {
  margin-top: 14px;
}
.advanced-analysis-title {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 14px;
}
.advanced-analysis-title h3 {
  margin: 0;
  color: var(--text-main);
  font-size: 14px;
}
.advanced-analysis-title small {
  color: var(--text-muted);
  font-size: 11px;
}
.sales-trend-chart {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  height: 170px;
  gap: 5px;
  padding-top: 10px;
  border-bottom: 1px solid var(--border-glass);
}
.trend-column {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}
.trend-column small {
  color: var(--text-subtle);
  font-size: 9px;
  direction: ltr;
}
.trend-bars {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  width: 100%;
  height: 135px;
  gap: 2px;
}
.trend-bars i {
  display: block;
  width: 7px;
  min-height: 2px;
  border-radius: 3px 3px 0 0;
}
.trend-expected { background: rgba(245, 158, 11, .55); }
.trend-received { background: var(--emerald-neon); }
.sales-insights-list {
  display: grid;
  gap: 12px;
}
.sales-insight-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-glass);
}
.sales-insight-item > span {
  color: var(--emerald-neon);
  font-size: 18px;
  line-height: 1;
}
.sales-insight-item p {
  margin: 0;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.5;
}
.advanced-products-table {
  overflow-x: auto;
}
.advanced-table-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.7fr) .7fr 1fr 1fr;
  align-items: center;
  gap: 12px;
  min-width: 560px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--border-glass);
  color: var(--text-muted);
  font-size: 12px;
}
.advanced-table-row strong {
  overflow: hidden;
  color: var(--text-main);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.advanced-table-header {
  color: var(--text-subtle);
  font-size: 11px;
  font-weight: 700;
}
.profit-positive { color: var(--emerald-neon); font-weight: 700; }
.profit-missing { color: var(--gold-amber); font-size: 11px; }
/* Keep public-store controls out of the back office, especially on phones. */
.admin-shell .chat-widget-btn,
.admin-shell .chat-window,
.admin-shell .mobile-bottom-nav,
.admin-shell .mobile-product-sticky-bar,
.admin-shell .site-public-nav,
.admin-shell .site-public-actions {
  display: none !important;
}
.admin-shell .admin-tabs-nav {
  scrollbar-width: thin;
}
.admin-tabs-nav {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border-glass);
  padding-bottom: 12px;
  overflow-x: auto;
}
.admin-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: var(--border-glass);
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.92rem;
  cursor: pointer;
  transition: all 0.2s ease;
}
.admin-tab-btn.active {
  background: var(--emerald-gradient);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 15px var(--emerald-glow);
}
.tab-badge {
  background: var(--gold-amber);
  color: #000;
  font-size: 0.72rem;
  padding: 1px 7px;
  border-radius: var(--radius-full);
}
.admin-tab-pane { display: none; }
.admin-tab-pane.active { display: block; }

/* Admin Chat Inbox Layout */
.admin-chat-grid {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 20px;
  height: 620px;
  background: var(--bg-card);
  border: 1px solid var(--emerald-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-subtle);
}
.admin-chat-threads {
  border-left: 1px solid var(--border-glass);
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
}
body[dir="rtl"] .admin-chat-threads { border-left: none; border-right: 1px solid var(--border-glass); }
.admin-threads-head {
  padding: 16px;
  font-weight: 700;
  border-bottom: 1px solid var(--border-glass);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.threads-list { flex: 1; overflow-y: auto; }
.thread-item {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-glass);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.thread-item:hover, .thread-item.active { background: var(--bg-card-hover); }
.thread-item strong { font-size: 0.88rem; color: var(--text-main); display: flex; justify-content: space-between; }
.thread-item p { font-size: 0.78rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.admin-chat-active-window {
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
}
.admin-chat-conv-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-glass);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.admin-conv-messages {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--bg-surface);
}
.admin-chat-reply-bar {
  padding: 14px 20px;
  border-top: 1px solid var(--border-glass);
  display: flex;
  gap: 10px;
}
.admin-chat-reply-bar input {
  flex: 1;
  padding: 10px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-full);
  color: var(--text-main);
}
.admin-chat-reply-bar button {
  padding: 10px 20px;
  background: var(--emerald-gradient);
  color: #fff;
  border: none;
  border-radius: var(--radius-full);
  font-weight: 700;
  cursor: pointer;
}
.admin-chat-image-btn {
  flex: 0 0 38px;
  width: 38px;
  padding: 0 !important;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}
.admin-chat-image-preview {
  display: flex;
  gap: 8px;
  padding: 0 20px 10px;
  background: var(--bg-surface-secondary);
}
.admin-chat-image-preview img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 8px;
}
.admin-chat-image-preview button {
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
}
.admin-chat-input-error {
  padding: 0 20px 8px;
  color: #fca5a5;
  font-size: 12px;
}

/* ==========================================================================
   Mobile Bottom Navigation Bar (App-like Experience for Smartphones)
   ========================================================================== */
.mobile-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(62px + env(safe-area-inset-bottom));
  background: var(--bg-glass-heavy);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-top: 1px solid var(--border-glass);
  display: none;
  justify-content: space-around;
  align-items: center;
  z-index: 13000;
  padding: 4px 8px calc(env(safe-area-inset-bottom) + 2px);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.4);
}

.mobile-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 600;
  text-decoration: none;
  padding: 6px 0;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
  position: relative;
  touch-action: manipulation;
  background: none;
  border: none;
  cursor: pointer;
}

.mobile-nav-item:hover, .mobile-nav-item.active {
  color: var(--emerald-neon);
}

.mobile-nav-item.active .mobile-nav-icon {
  transform: translateY(-2px) scale(1.1);
  filter: drop-shadow(0 0 8px var(--emerald-neon));
}

.mobile-nav-icon {
  font-size: 1.25rem;
  line-height: 1;
  display: inline-block;
  transition: transform 0.2s ease;
}

.mobile-nav-badge {
  position: absolute;
  top: 2px;
  right: calc(50% - 18px);
  background: var(--gold-amber);
  color: #000;
  font-size: 0.65rem;
  font-weight: 900;
  padding: 1px 5px;
  border-radius: var(--radius-full);
  min-width: 16px;
  text-align: center;
  line-height: 14px;
}

body[dir="rtl"] .mobile-nav-badge {
  right: auto;
  left: calc(50% - 18px);
}

/* Mobile Sticky Product Buy Bar */
.mobile-product-sticky-bar {
  position: fixed;
  bottom: calc(62px + env(safe-area-inset-bottom));
  left: 0;
  right: 0;
  background: var(--bg-glass-heavy);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--emerald-border);
  padding: 8px 14px;
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  z-index: 990;
  box-shadow: 0 -6px 25px rgba(0, 0, 0, 0.45);
}

.mobile-sticky-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.mobile-sticky-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mobile-sticky-price {
  font-size: 1.05rem;
  font-weight: 900;
  color: var(--emerald-neon);
  font-family: 'Space Grotesk', sans-serif;
}

.btn-mobile-sticky-buy {
  background: var(--emerald-gradient);
  color: #032115;
  font-weight: 800;
  font-size: 0.88rem;
  padding: 10px 18px;
  border-radius: var(--radius-full);
  border: none;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 4px 15px var(--emerald-glow);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* ==========================================================================
   Comprehensive Responsive Adaptations (Mobile & Tablet First)
   ========================================================================== */

/* Tablets & Small Laptops (max-width: 1024px) */
@media (max-width: 1024px) {
  .hero-grid {
    grid-template-columns: 1fr 0.9fr;
    gap: 28px;
  }
  .calc-grid {
    grid-template-columns: 1.1fr 0.9fr;
    gap: 20px;
  }
  .product-detail-layout {
    grid-template-columns: 1fr 1fr;
    gap: 24px;
  }
  .footer-grid {
    grid-template-columns: 1.4fr 1fr 1fr;
    gap: 30px;
  }
}

/* Medium Tablets & Large Phones (max-width: 860px) */
@media (max-width: 860px) {
  .hero-grid {
    grid-template-columns: 1fr;
    gap: 32px;
  }
  .hero-visual-wrap {
    max-width: 480px;
    margin: 0 auto;
    width: 100%;
  }
  .calc-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  .cart-layout {
    grid-template-columns: 1fr;
  }
  .cart-summary-box {
    position: static;
  }
  .catalog-layout {
    grid-template-columns: 1fr;
  }
  .admin-chat-grid {
    grid-template-columns: 1fr;
    height: auto;
  }
}

/* Smartphones & Small Tablets (max-width: 768px) */
@media (max-width: 768px) {
  .admin-course-row { grid-template-columns: 46px 1fr; }
  .admin-course-icon { width: 46px; height: 46px; }
  .admin-course-actions { grid-column: 1 / -1; }
  .admin-course-actions button { flex: 1; }
  /* Show Mobile Bottom Navigation */
  .mobile-bottom-nav {
    display: flex;
  }
  body {
    padding-bottom: calc(68px + env(safe-area-inset-bottom));
  }

  /* Top Announcement Bar */
  .announcement {
    padding: 6px 0;
    font-size: 0.78rem;
  }
  .announcement-inner {
    flex-direction: column;
    gap: 6px;
    text-align: center;
  }
  .announcement-ticker {
    justify-content: center;
    font-size: 0.76rem;
  }
  .top-bar-tools {
    justify-content: center;
  }

  /* Site Header */
  .site-header {
    position: sticky;
    top: 0;
  }
  .header-main {
    height: auto;
    padding: 10px 0 12px;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    align-items: center;
  }
  .brand {
    gap: 10px;
  }
  .brand-emblem {
    width: 40px;
    height: 40px;
    border-radius: 10px;
  }
  .brand-name {
    font-size: 1.3rem;
  }
  .brand-tagline {
    display: none;
  }

  .search-bar {
    grid-column: 1 / -1;
    order: 3;
    max-width: 100%;
    width: 100%;
    margin-top: 2px;
  }
  .search-bar input {
    height: 42px;
    font-size: 16px; /* Prevents iOS auto-zoom */
    padding: 0 18px 0 42px;
  }
  body[dir="rtl"] .search-bar input {
    padding: 0 42px 0 18px;
  }

  /* Mobile header: no floating controls in the top slot on phones.
     Account access on mobile is handled entirely by the bottom nav
     ("حسابي" tab), so the header profile button is hidden here to
     avoid a duplicate/floating icon overlapping the logo. */
  .header-actions {
    position: absolute;
    top: 10px;
    left: 12px;
    right: auto;
    width: auto;
    display: flex;
    gap: 0;
    overflow: visible;
    padding: 0;
    z-index: 20;
  }
  .header-actions .cart-btn,
  .header-actions .orders-btn,
  .header-actions .header-all-products-btn,
  .header-actions .profile-btn {
    display: none !important;
  }

  /* Category Navigation */
  .category-nav-inner {
    padding: 8px 0;
    gap: 6px;
  }
  .category-nav {
    display: none;
  }
  .cat-link {
    padding: 5px 12px;
    font-size: 0.78rem;
    flex-shrink: 0;
  }

  /* Hero Section */
  .hero-section {
    padding: 24px 0 30px;
  }
  .hero-content {
    gap: 16px;
    text-align: center;
    align-items: center;
  }
  .hero-title {
    font-size: clamp(1.7rem, 6vw, 2.3rem);
    letter-spacing: -0.5px;
    line-height: 1.25;
  }
  .hero-description {
    font-size: 0.95rem;
    line-height: 1.55;
  }
  .hero-actions {
    width: 100%;
    flex-direction: column;
    gap: 10px;
  }
  .hero-actions a, .hero-actions button {
    width: 100%;
    justify-content: center;
    padding: 13px 20px;
    font-size: 0.95rem;
  }

  /* Mobile touch reliability */
  a, button, input, select, textarea {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }
  .hero-actions a, .hero-actions button,
  .theme-toggle-btn, .lang-switch-btn,
  .chat-widget-btn, .chat-send-btn, .chat-image-btn {
    min-height: 44px;
  }
  #flash, #calculator {
    scroll-margin-top: 90px;
  }

  .hero-stats {
    width: 100%;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding-top: 14px;
  }
  .stat-item {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    padding: 10px 8px;
    text-align: center;
  }
  .stat-item strong {
    font-size: 1.2rem;
  }
  .stat-item span {
    font-size: 0.72rem;
  }

  .floating-glass-badge {
    padding: 6px 10px;
    gap: 6px;
    max-width: calc(100% - 24px);
  }
  .floating-glass-badge strong {
    font-size: 0.76rem !important;
  }
  .floating-glass-badge small {
    font-size: 0.65rem !important;
  }
  .badge-icon-gold, .badge-icon-emerald {
    width: 24px;
    height: 24px;
    font-size: 0.85rem;
  }

  /* Trust Grid */
  .trust-section {
    padding: 16px 0 24px;
  }
  .trust-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .trust-box {
    padding: 12px 10px;
    gap: 10px;
  }
  .trust-icon-wrap {
    width: 36px;
    height: 36px;
    font-size: 1.1rem;
    border-radius: 8px;
  }
  .trust-text h4 {
    font-size: 0.82rem;
  }
  .trust-text p {
    font-size: 0.7rem;
  }

  /* 58 Wilayas Calculator */
  .calculator-section {
    padding: 24px 0 32px;
  }
  .calculator-card {
    padding: 20px 14px;
    border-radius: var(--radius-md);
  }
  .calc-header {
    margin-bottom: 18px;
  }
  .calc-header h2 {
    font-size: 1.35rem;
  }
  .calc-header p {
    font-size: 0.84rem;
  }
  .custom-select {
    height: 46px;
    font-size: 16px; /* Prevents iOS auto-zoom */
  }
  .calc-result-box {
    padding: 16px 14px;
    gap: 12px;
  }
  .result-value {
    font-size: 1.2rem;
  }

  /* Product Section & Flagship Grid (2 Columns on Mobile) */
  .flash-section {
    padding: 24px 0;
  }
  .flash-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  .flash-header h2 {
    font-size: 1.35rem;
  }
  .home-cat-pills {
    flex-wrap: nowrap;
    gap: 6px;
    padding: 6px 0 14px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }
  .cat-pill {
    padding: 6px 12px;
    font-size: 12px;
    flex-shrink: 0;
  }

  .flagship-grid, .dense-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }
  .product-card, .dense-card {
    border-radius: var(--radius-sm);
    min-width: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
  }
  .card-body, .dc-body {
    padding: 10px 8px 12px;
    min-width: 0 !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }
  .card-cat, .card-category {
    font-size: 0.68rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
  }
  .card-title, .dc-body h3 {
    font-size: 0.82rem !important;
    height: 36px !important;
    line-height: 1.3 !important;
    margin-bottom: 6px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
  }
  .card-price-row {
    margin-bottom: 8px;
    gap: 4px;
    flex-wrap: wrap;
  }
  .price-dzd, .dc-body .price {
    font-size: 0.98rem !important;
    white-space: nowrap;
  }
  .price-old {
    font-size: 0.72rem;
  }
  .price-usd {
    display: none;
  }
  .card-btn-group, .card-actions {
    grid-template-columns: 1fr !important;
    gap: 5px !important;
    width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }
  .btn-card-details, .btn-card-express, .card-view, .card-add {
    padding: 7px 6px;
    font-size: 0.76rem !important;
    text-align: center !important;
    width: 100% !important;
    min-width: 0 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    box-sizing: border-box !important;
    display: block !important;
  }

  /* Product Details Page (produit.html) */
  .product-detail-layout {
    grid-template-columns: 1fr;
    gap: 20px;
    padding: 16px 0 40px;
  }
  .main-img-box {
    border-radius: var(--radius-md);
  }
  .thumbs-strip {
    gap: 8px;
  }
  .thumb-item {
    width: 64px;
    height: 64px;
  }
  .prod-main-title {
    font-size: 1.35rem;
  }
  .price-box-luxury {
    padding: 14px 16px;
  }
  .price-tag-dzd {
    font-size: 1.6rem;
  }
  .qty-and-cta-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .qty-stepper {
    height: 44px;
  }
  .qty-btn {
    width: 44px;
    height: 44px;
  }
  .specs-table td {
    padding: 8px 10px;
    font-size: 0.82rem;
  }

  /* Cart Page (panier.html) */
  .cart-page {
    padding: 20px 0 60px;
  }
  .cart-items-box, .cart-summary-box {
    padding: 16px 14px;
  }
  .cart-item-row {
    grid-template-columns: 68px 1fr auto;
    gap: 10px;
    padding: 12px 0;
  }
  .cart-item-row img {
    width: 68px;
    height: 68px;
  }
  .cart-item-row h3 {
    font-size: 0.86rem;
  }

  /* Modals & Popups */
  .modal-overlay, .welcome-modal-overlay {
    padding: 10px;
    align-items: flex-end;
  }
  .modal-container, .welcome-modal-card {
    border-radius: 20px 20px 10px 10px;
    padding: 20px 16px;
    max-height: 88vh;
    width: 100%;
  }
  .modal-field input, .modal-field select, .modal-field textarea {
    font-size: 16px; /* Prevents iOS auto-zoom */
    padding: 10px 12px;
  }
  .modal-head {
    padding: 14px 16px;
  }
  .modal-body {
    padding: 16px 0 8px;
    gap: 14px;
  }

  /* Live Chat Widget on Mobile */
  .chat-widget-btn {
    bottom: calc(72px + env(safe-area-inset-bottom));
    right: auto;
    left: 14px;
    width: 50px;
    height: 50px;
    font-size: 1.35rem;
    z-index: 992;
  }
  body[dir="rtl"] .chat-widget-btn {
    left: 14px;
    right: auto;
  }

  .chat-window {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: var(--app-height, 100vh);
    max-width: 100%;
    border-radius: 0;
    z-index: 10005;
    bottom: 0;
    left: 0;
    right: 0;
    top: 0;
  }
  body[dir="rtl"] .chat-window {
    left: 0;
    right: 0;
  }
  .chat-input-bar input {
    font-size: 16px;
  }

  /* Sales Toast */
  .sales-toast {
    bottom: calc(72px + env(safe-area-inset-bottom));
    left: 10px;
    right: 10px;
    max-width: calc(100vw - 20px);
    font-size: 0.8rem;
    padding: 8px 12px;
  }
  body[dir="rtl"] .sales-toast {
    left: 10px;
    right: 10px;
  }

  /* Reviews & Social Proof */
  .reviews-section {
    padding: 30px 0;
  }
  .reviews-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .review-card {
    padding: 16px 14px;
  }

  /* Footer */
  .site-footer {
    padding: 36px 0 20px;
    margin-top: 36px;
  }
  .footer-grid {
    grid-template-columns: 1fr;
    gap: 24px;
    text-align: center;
  }
  .footer-brand-col {
    display: flex;
    flex-direction: column;
    align-items: center;
  }
  .footer-brand-col p {
    max-width: 100%;
  }
  .footer-bottom {
    flex-direction: column;
    gap: 8px;
    text-align: center;
    font-size: 0.75rem;
  }
}

/* Sales center: compact retail-dashboard presentation */
.admin-analysis-panel {
  position: relative;
  padding: 26px;
  background: linear-gradient(145deg, var(--bg-card), var(--bg-surface));
  border-color: rgba(0, 229, 153, .22);
}
.admin-analysis-panel::before {
  position: absolute;
  top: 0;
  right: 28px;
  left: 28px;
  height: 2px;
  background: var(--emerald-gradient);
  content: "";
}
.admin-analysis-head {
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border-glass);
}
.admin-analysis-head h2 {
  margin: 5px 0 0;
  font-size: 24px;
  letter-spacing: 0;
}
.admin-analysis-head .hero-pill {
  padding: 3px 10px;
  font-size: 10px;
  letter-spacing: .4px;
}
.admin-analysis-head select {
  min-width: 132px;
  border-color: rgba(0, 229, 153, .3);
  font-weight: 700;
}
.sales-analysis-grid {
  grid-template-columns: repeat(auto-fit, minmax(165px, 1fr));
  gap: 10px;
  margin: 18px 0;
}
.sales-analysis-card {
  position: relative;
  min-height: 96px;
  padding: 15px 16px;
  border-color: var(--border-glass);
  border-radius: 10px;
  background: rgba(7, 12, 10, .16);
}
.sales-analysis-card::after {
  position: absolute;
  right: 0;
  bottom: 12px;
  width: 3px;
  height: 28px;
  border-radius: 3px 0 0 3px;
  background: var(--emerald-neon);
  content: "";
}
.sales-analysis-card span { font-size: 11px; }
.sales-analysis-card strong { margin: 10px 0 5px; font-size: 20px; }
.sales-analysis-card small { font-size: 10px; }
.sales-analysis-columns,
.advanced-analysis-grid {
  gap: 12px;
}
.sales-analysis-columns > div,
.advanced-analysis-card {
  padding: 17px;
  border: 1px solid var(--border-glass);
  border-radius: 10px;
  background: rgba(7, 12, 10, .12);
}
.sales-analysis-columns h3 { margin-bottom: 15px; font-size: 13px; }
.advanced-analysis-card { margin-top: 12px; }
.advanced-table-card { padding: 18px; }
.advanced-analysis-title { margin-bottom: 12px; }
.advanced-analysis-title h3 { font-size: 13px; }
.advanced-analysis-title small { font-size: 10px; }
.sales-trend-chart { height: 185px; }
.trend-bars { height: 150px; }
.trend-bars i { width: 8px; }
.advanced-table-row { padding: 12px 6px; }

@media (max-width: 768px) {
  .admin-analysis-panel { padding: 20px 13px; }
  .admin-analysis-head h2 { font-size: 20px; }
  .admin-analysis-head select { width: 100%; }
  .sales-analysis-card { min-height: 88px; }
}

/* Very Small Phones (max-width: 380px) */
@media (max-width: 380px) {
  .hero-title {
    font-size: 1.55rem;
  }
  .trust-grid {
    grid-template-columns: 1fr;
  }
  .floating-glass-badge {
    display: none; /* Hide floating badges on ultra small screens to prevent clipping */
  }
  .flagship-grid, .dense-grid {
    grid-template-columns: 1fr !important;
  }
}

/* ==========================================================================
   Desktop & Widescreen Enhancements (min-width: 1024px)
   ========================================================================== */
@media (min-width: 1024px) {
  /* Hide mobile-only elements on desktop */
  .mobile-bottom-nav {
    display: none !important;
  }
  .mobile-product-sticky-bar {
    display: none !important;
  }

  /* Desktop body should NOT have bottom padding for mobile nav */
  body {
    padding-bottom: 0 !important;
  }
  body.has-bottom-nav {
    padding-bottom: 0 !important;
  }

  /* Ensure header shows full actions on desktop */
  .header-actions .action-btn span {
    display: inline !important;
  }
  .header-all-products-btn {
    display: inline-flex !important;
  }
  .header-actions .orders-btn {
    display: inline-flex !important;
  }

  /* Sticky header with subtle shadow on desktop */
  .site-header {
    position: sticky;
    top: 0;
  }

  /* Hero: proper two-column on desktop */
  .hero-grid {
    grid-template-columns: 1.15fr 0.85fr;
    gap: 40px;
  }
  .hero-content {
    text-align: initial;
    align-items: flex-start;
  }
  .hero-actions {
    flex-direction: row;
    width: auto;
  }
  .hero-actions a, .hero-actions button {
    width: auto;
  }
  .hero-stats {
    grid-template-columns: repeat(4, 1fr);
  }
  .stat-item {
    background: transparent;
    border: none;
    padding: 0;
    text-align: initial;
  }

  body[dir="rtl"] .hero-content {
    text-align: right;
    align-items: flex-start;
  }

  /* Trust grid: full 4 columns on desktop */
  .trust-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  /* Calculator: two columns */
  .calc-grid {
    grid-template-columns: 1.2fr 0.8fr;
    gap: 30px;
  }

  /* Product grids: proper fill on desktop */
  .flagship-grid {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)) !important;
    gap: 22px !important;
  }
  .dense-grid {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)) !important;
    gap: 18px !important;
  }

  /* Cards: show full button text and groups on desktop */
  .card-btn-group, .card-actions {
    grid-template-columns: 1fr 1.2fr !important;
    gap: 8px !important;
  }
  .price-usd {
    display: inline !important;
  }

  /* Product Detail: two columns */
  .product-detail-layout {
    grid-template-columns: 1fr 1fr;
    gap: 36px;
  }
  .qty-and-cta-grid {
    grid-template-columns: auto 1fr;
  }

  /* Cart: two columns */
  .cart-layout {
    grid-template-columns: 2fr 1fr;
  }

  /* Modals: centered on desktop */
  .modal-overlay, .welcome-modal-overlay {
    padding: 20px;
    align-items: center;
  }
  .modal-container, .welcome-modal-card {
    border-radius: var(--radius-lg);
    width: min(520px, 100%);
  }

  /* Footer: full 4 columns */
  .footer-grid {
    grid-template-columns: 1.5fr 1fr 1fr 1fr;
    gap: 40px;
    text-align: initial;
  }
  .footer-brand-col {
    align-items: flex-start;
  }
  .footer-bottom {
    flex-direction: row;
    text-align: initial;
  }

  body[dir="rtl"] .footer-grid {
    text-align: right;
  }
  body[dir="rtl"] .footer-brand-col {
    align-items: flex-start;
  }
  body[dir="rtl"] .footer-bottom {
    text-align: right;
  }

  /* Admin chat grid: side-by-side */
  .admin-chat-grid {
    grid-template-columns: 320px 1fr;
    height: 620px;
  }

  /* Reviews: 3 columns on desktop */
  .reviews-grid {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  }

  /* Announcement bar: side by side */
  .announcement-inner {
    flex-direction: row;
    text-align: initial;
  }
  .announcement-ticker {
    justify-content: flex-start;
  }

  /* Category pills: wrap on desktop */
  .home-cat-pills {
    flex-wrap: wrap;
    overflow-x: visible;
  }

  /* Flash header: row layout */
  .flash-header {
    flex-direction: row;
    align-items: center;
  }
}

/* ==========================================================================
   Ultra-Widescreen (min-width: 1440px) — Prevent content stretching
   ========================================================================== */
@media (min-width: 1440px) {
  .container {
    width: min(1320px, calc(100% - 48px));
  }
  .hero-title {
    font-size: 3.5rem;
  }
  .flagship-grid {
    grid-template-columns: repeat(4, 1fr) !important;
  }
}

/* ==========================================================================
   Desktop Polish: Scrollbar, Focus & Selection
   ========================================================================== */
/* Custom scrollbar for desktop browsers */
::-webkit-scrollbar {
  width: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-surface);
}
::-webkit-scrollbar-thumb {
  background: var(--emerald-deep);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--emerald-neon);
}

/* Focus ring for keyboard navigation (accessibility) */
*:focus-visible {
  outline: 2px solid var(--emerald-neon);
  outline-offset: 2px;
}

/* Selection color */
::selection {
  background: var(--emerald-glow);
  color: var(--text-main);
}

@media (max-width: 768px) {
  .admin-analysis-panel {
    padding: 16px 12px;
  }
  .admin-analysis-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }
  .sales-analysis-grid,
  .sales-analysis-columns,
  .advanced-analysis-grid {
    grid-template-columns: 1fr;
  }
  .advanced-analysis-title {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }
}

/* ===== مساعد المبيعات الذكي (AI Sales Assistant) ===== */
.ai-sales-assistant {
  background: var(--bg-card);
  border: 1px solid var(--emerald-border);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-top: 20px;
}
.ai-sales-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 6px;
}
.ai-sales-head h2 {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-main);
  margin: 4px 0 0;
}
.ai-sales-hint {
  color: var(--text-muted);
  font-size: 13px;
  margin: 0 0 14px;
}
.ai-sales-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}
.ai-sales-chip {
  background: var(--bg-main);
  border: 1px solid var(--emerald-border);
  color: var(--text-main);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.15s ease;
  white-space: nowrap;
}
.ai-sales-chip:hover {
  background: var(--emerald-gradient);
  color: #04140d;
  transform: translateY(-1px);
}
.ai-sales-messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 320px;
  overflow-y: auto;
  padding: 4px 2px 10px;
  margin-bottom: 12px;
}
.ai-sales-bubble {
  max-width: 92%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.7;
  white-space: pre-wrap;
}
.ai-sales-bubble.user {
  align-self: flex-end;
  background: var(--emerald-gradient);
  color: #04140d;
  font-weight: 600;
}
.ai-sales-bubble.ai {
  align-self: flex-start;
  background: var(--bg-main);
  border: 1px solid var(--border-glass);
  color: var(--text-main);
}
.ai-sales-bubble.thinking {
  opacity: 0.7;
  font-style: italic;
}
.ai-sales-form {
  display: flex;
  gap: 10px;
}
.ai-sales-form input {
  flex: 1;
  padding: 10px 14px;
  background: var(--bg-main);
  border: 1px solid var(--border-glass);
  border-radius: 8px;
  color: var(--text-main);
  font-size: 14px;
}
@media (max-width: 640px) {
  .ai-sales-form { flex-direction: column; }
  .ai-sales-bubble { max-width: 100%; }
}


/* Mobile navigation reliability fixes */
@media (max-width: 768px) {
  body.has-bottom-nav {
    padding-bottom: calc(76px + env(safe-area-inset-bottom));
  }
  .mobile-bottom-nav {
    min-height: calc(66px + env(safe-area-inset-bottom));
    padding-bottom: calc(4px + env(safe-area-inset-bottom));
    padding-left: max(6px, env(safe-area-inset-left));
    padding-right: max(6px, env(safe-area-inset-right));
    pointer-events: auto;
    -webkit-tap-highlight-color: transparent;
  }
  .mobile-nav-item {
    min-width: 0;
    min-height: 54px;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
  }
  .mobile-nav-label {
    display: block;
    white-space: nowrap;
    line-height: 1.15;
    font-size: .68rem;
    pointer-events: none;
  }
  .mobile-nav-icon { pointer-events: none; }
  .chat-widget-btn {
    bottom: calc(82px + env(safe-area-inset-bottom));
    z-index: 13100;
  }
  .chat-window {
    bottom: calc(146px + env(safe-area-inset-bottom));
    z-index: 13101;
  }
}

/* ===== Account / Profile system (desktop + mobile) ===== */
.profile-btn.is-authenticated { border-color: var(--emerald-neon); }
.profile-btn .profile-avatar-icon { display:none; }
.profile-btn.is-authenticated .profile-avatar-icon { display:inline-grid; }
.algcool-profile-overlay { z-index: 12000; padding: 24px; }
.algcool-profile-auth-modal { width: min(520px, 100%); max-height: min(760px, 92vh); overflow: hidden; display:flex; flex-direction:column; }
.algcool-profile-head { flex: 0 0 auto; padding: 22px 24px; background: linear-gradient(135deg, rgba(16,185,129,.12), transparent 55%); }
.algcool-profile-head h3 { margin: 3px 0 0; }
.algcool-profile-kicker { display:block; font-size:.66rem; letter-spacing:.13em; color:var(--emerald-neon); font-weight:800; }
.algcool-profile-body { padding:24px; overflow:auto; gap:16px; }
.algcool-auth-intro { display:flex; align-items:center; gap:13px; padding:2px 0 4px; }
.algcool-auth-logo,.algcool-account-avatar { width:54px; height:54px; flex:0 0 54px; display:grid; place-items:center; border-radius:18px; background:var(--emerald-gradient); color:#fff; font-size:1.45rem; font-weight:900; box-shadow:0 10px 24px var(--emerald-glow); }
.algcool-auth-intro h4 { margin:0 0 4px; font-size:1.08rem; color:var(--text-main); }
.algcool-auth-intro p { margin:0; color:var(--text-muted); font-size:.84rem; line-height:1.6; }
.profile-auth-tabs { display:grid; grid-template-columns:1fr 1fr; gap:7px; padding:5px; border-radius:14px; background:var(--bg-surface); border:1px solid var(--border-glass); }
.profile-tab { min-height:44px; border:0; border-radius:10px; background:transparent; color:var(--text-muted); font:inherit; font-weight:800; cursor:pointer; transition:.2s ease; }
.profile-tab.active { color:#fff; background:var(--emerald-gradient); box-shadow:0 8px 18px rgba(16,185,129,.18); }
.algcool-auth-form { display:flex; flex-direction:column; gap:14px; }
.algcool-auth-field { display:flex; flex-direction:column; gap:7px; color:var(--text-main); font-size:.84rem; font-weight:800; }
.algcool-auth-field input { width:100%; box-sizing:border-box; min-height:48px; padding:12px 14px; border-radius:12px; border:1px solid var(--border-glass); background:var(--bg-surface); color:var(--text-main); font:inherit; font-size:16px; outline:none; transition:border-color .2s, box-shadow .2s; }
.algcool-auth-field input:focus { border-color:var(--emerald-neon); box-shadow:0 0 0 3px rgba(16,185,129,.12); }
.algcool-password-wrap { position:relative; display:block; }
.algcool-password-wrap input { padding-inline-end:70px; }
.algcool-password-toggle { position:absolute; inset-inline-end:8px; top:50%; transform:translateY(-50%); border:0; background:transparent; color:var(--emerald-neon); font:inherit; font-size:.76rem; font-weight:800; cursor:pointer; padding:7px; }
.algcool-auth-submit { width:100%; min-height:50px; margin-top:2px; font-size:.96rem; }
.algcool-auth-submit:disabled,.algcool-account-action:disabled { opacity:.65; cursor:wait; }
.algcool-auth-secondary { border:0; background:transparent; color:var(--emerald-neon); font:inherit; font-size:.82rem; font-weight:800; cursor:pointer; padding:5px; }
.algcool-auth-note { margin:0; text-align:center; color:var(--text-muted); font-size:.7rem; line-height:1.6; }
/* الحساب اختياري، ونافذة الملف الشخصي لا تظهر إلا بعد الضغط على زر الملف الشخصي. */
.algcool-profile-message { min-height:20px; text-align:center; color:var(--text-muted); font-size:.82rem; font-weight:700; line-height:1.5; }
.algcool-profile-message.error { color:#dc2626; }
.algcool-profile-message.success { color:var(--emerald-neon); }
.algcool-account-card { display:grid; grid-template-columns:auto 1fr; gap:12px; align-items:center; padding:17px; border:1px solid var(--emerald-border); border-radius:18px; background:linear-gradient(135deg, var(--bg-surface), rgba(16,185,129,.06)); }
.algcool-account-meta { min-width:0; display:flex; flex-direction:column; gap:4px; }
.algcool-account-meta strong { color:var(--text-main); font-size:1rem; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.algcool-account-meta span { color:var(--text-muted); font-size:.78rem; overflow-wrap:anywhere; direction:ltr; text-align:right; }
.algcool-account-status { grid-column:2; color:var(--emerald-neon); font-size:.7rem; font-weight:800; }
.algcool-account-actions { display:flex; flex-direction:column; gap:9px; }
.algcool-account-action { width:100%; display:grid; grid-template-columns:auto 1fr auto; align-items:center; gap:12px; text-align:right; padding:13px 14px; border:1px solid var(--border-glass); border-radius:14px; background:var(--bg-surface); color:var(--text-main); cursor:pointer; transition:.2s ease; }
.algcool-account-action:hover { border-color:var(--emerald-border); transform:translateY(-1px); }
.algcool-account-action.primary { border-color:var(--emerald-border); }
.algcool-account-action span:nth-child(2) { display:flex; flex-direction:column; gap:3px; }
.algcool-account-action small { color:var(--text-muted); font-size:.72rem; font-weight:600; }
.algcool-action-icon { width:38px; height:38px; display:grid; place-items:center; border-radius:11px; background:rgba(16,185,129,.1); }
.algcool-account-action i { color:var(--emerald-neon); font-size:1.4rem; font-style:normal; }
.algcool-logout-btn { width:100%; min-height:46px; border:1px solid rgba(220,38,38,.25); border-radius:12px; background:transparent; color:#dc2626; font:inherit; font-weight:800; cursor:pointer; }
.algcool-logout-btn:hover { background:rgba(220,38,38,.06); }
@media (max-width: 640px) {
  .algcool-profile-overlay { padding:0; align-items:flex-end; }
  .algcool-profile-auth-modal { width:100%; max-height:92dvh; border-radius:24px 24px 0 0; }
  .algcool-profile-head { padding:18px 18px 14px; }
  .algcool-profile-body { padding:18px 16px calc(20px + env(safe-area-inset-bottom)); }
  .algcool-auth-intro { align-items:flex-start; }
  .algcool-account-card { padding:14px; }
}
@media (min-width: 641px) {
  .algcool-profile-overlay { align-items:center; }
  .algcool-profile-auth-modal { border-radius:22px; }
}
.profile-btn .profile-static-icon { display:inline-block; }
.profile-btn.is-authenticated .profile-static-icon { display:none; }


/* Admin chat: conversation list is always a clean vertical stack. On small screens,
   selecting a conversation focuses only that conversation. */
.admin-chat-threads .threads-list{display:flex;flex-direction:column;gap:8px;overflow-y:auto;overflow-x:hidden;padding:8px;}
.admin-chat-threads .threads-list > button{margin-bottom:0!important;flex:0 0 auto;}
@media(max-width:768px){
  .admin-chat-grid{grid-template-columns:1fr!important;height:620px!important;position:relative;}
  .admin-chat-grid .admin-chat-active-window{display:none;}
  .admin-chat-grid.chat-active-only .admin-chat-threads{display:none;}
  .admin-chat-grid.chat-active-only .admin-chat-active-window{display:flex;min-height:0;}
}

/* صفحة "الدورات": رابط رجوع واضح وسلس إلى الرئيسية في نسخة الحاسوب فقط. */
.courses-back-link {
  display: none;
}
@media (min-width: 769px) {
  .courses-back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 18px;
    padding: 9px 18px;
    border: 1px solid var(--emerald-border);
    border-radius: var(--radius-full);
    background: var(--bg-surface);
    color: var(--text-main);
    font-weight: 700;
    font-size: 0.92rem;
    text-decoration: none;
    transition: all 0.2s ease;
  }
  .courses-back-link:hover {
    border-color: var(--emerald-neon);
    color: var(--emerald-neon);
    box-shadow: 0 0 15px var(--emerald-glow);
    transform: translateY(-1px);
  }
}




/* Desktop theme button interaction fix */
.theme-toggle-btn { position: relative; z-index: 10001; pointer-events: auto !important; cursor: pointer; }


/* ==========================================================================
   FINAL THEME CONSISTENCY FIX
   chat-fix.css used to force html/body to white, which overrode the theme
   variables and produced a mixed light/dark page.
   ========================================================================== */
html[data-theme="dark"],
html[data-theme="dark"] body {
  background-color: var(--bg-main) !important;
  color: var(--text-main) !important;
}
html[data-theme="light"],
html[data-theme="light"] body {
  background-color: var(--bg-main) !important;
  color: var(--text-main) !important;
}
html[data-theme="dark"] .hero-section,
html[data-theme="dark"] .trust-section,
html[data-theme="dark"] .calculator-section,
html[data-theme="dark"] .flash-section,
html[data-theme="dark"] .reviews-section {
  background-color: var(--bg-main) !important;
  color: var(--text-main);
}
html[data-theme="dark"] .chat-root {
  background: var(--bg-main) !important;
  color: var(--text-main) !important;
}
html[data-theme="dark"] .chat-composer,
html[data-theme="dark"] .chat-input {
  background: var(--bg-surface) !important;
  color: var(--text-main) !important;
  border-color: var(--border-glass) !important;
}
html[data-theme="dark"] input,
html[data-theme="dark"] textarea,
html[data-theme="dark"] select {
  color-scheme: dark;
}
html[data-theme="light"] input,
html[data-theme="light"] textarea,
html[data-theme="light"] select {
  color-scheme: light;
}
