:root {
  --green: #006233;
  --green-dark: #004d28;
  --red: #d21034;
  --red-dark: #a50d29;
  --sand: #f5f6f7;
  --sand-deep: #e8ecef;
  --sand-dark: #9ca3af;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --radius: 12px;
  font-size: 16px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { direction: rtl; }
body {
  font-family: 'Segoe UI', Tahoma, 'Noto Kufi Arabic', Arial, sans-serif;
  background: var(--sand); color: var(--text); line-height: 1.6;
}
a { color: var(--green); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea {
  font-family: inherit; font-size: 1rem; width: 100%;
  padding: 0.7rem 0.9rem; border: 1px solid var(--border); border-radius: 10px;
  background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--green); border-color: var(--green); }
label { display: block; font-weight: 600; margin: 0.8rem 0 0.3rem; font-size: 0.95rem; }

.container { max-width: 1100px; margin: 0 auto; padding: 0 1rem; }

/* Algerian flag strip */
.flag-strip { height: 5px; background: linear-gradient(to left, var(--green) 0 33.3%, #ffffff 33.3% 66.6%, var(--red) 66.6% 100%); }

/* Header */
.site-header { background: var(--green); color: #fff; position: sticky; top: 0; z-index: 50; box-shadow: 0 2px 10px rgba(0,0,0,0.15); }
.site-header .container { display: flex; align-items: center; gap: 0.7rem; padding: 0.6rem 1rem; flex-wrap: wrap; }
.logo { display: flex; align-items: center; gap: 0.45rem; font-size: 1.35rem; font-weight: 800; color: #fff; white-space: nowrap; }
.logo svg { flex-shrink: 0; }
.logo span { color: #d9eddf; font-weight: 400; font-size: 0.85rem; }
.search-box { flex: 1; min-width: 140px; }
.search-box input {
  border: 2px solid #fff; border-radius: 999px; background: #fff;
  padding: 0.55rem 1.1rem; font-size: 0.95rem;
}
.search-box input:focus { outline: none; border-color: var(--sand-deep); }
.header-links { display: flex; align-items: center; gap: 0.7rem; }
.header-links a { color: #fff; font-size: 0.9rem; font-weight: 600; }

.cart-btn {
  position: relative; background: var(--red); color: #fff; border: none;
  border-radius: 999px; padding: 0.5rem 1rem; font-size: 0.95rem; font-weight: 700;
}
.cart-btn:hover { background: var(--red-dark); }
.cart-count {
  position: absolute; top: -8px; left: -8px; background: #fff; color: var(--red);
  border-radius: 999px; min-width: 22px; height: 22px; font-size: 0.8rem; font-weight: 800;
  display: flex; align-items: center; justify-content: center; padding: 0 5px;
}

/* Hero */
.hero {
  background: linear-gradient(180deg, #ffffff 0%, #eef4ef 100%);
  color: var(--green-dark); padding: 2rem 0; text-align: center;
  border-bottom: 1px solid var(--border);
}
.hero h1 { font-size: 1.7rem; margin-bottom: 0.3rem; color: var(--green-dark); }
.hero p { color: var(--muted); font-weight: 600; }
.hero .hero-cta {
  display: inline-block; margin-top: 0.9rem; background: var(--red); color: #fff;
  padding: 0.6rem 1.5rem; border-radius: 999px; font-weight: 800; box-shadow: 0 3px 10px rgba(210,16,52,0.35);
}

/* Section titles */
.section-title { display: flex; align-items: center; gap: 0.5rem; margin: 1.3rem 0 0.8rem; font-size: 1.2rem; font-weight: 800; color: var(--green-dark); }
.section-title::after { content: ''; flex: 1; height: 2px; background: var(--sand-deep); border-radius: 2px; }

/* Category circles */
.cat-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0.7rem; }
.cat-circle { background: none; border: none; display: flex; flex-direction: column; align-items: center; gap: 0.35rem; }
.cat-circle .cc-icon {
  width: 58px; height: 58px; border-radius: 50%; background: var(--sand-deep);
  display: flex; align-items: center; justify-content: center; font-size: 1.6rem;
  border: 2px solid transparent; transition: border-color 0.15s;
}
.cat-circle.active .cc-icon, .cat-circle:hover .cc-icon { border-color: var(--green); background: #fff; }
.cat-circle .cc-name { font-size: 0.78rem; font-weight: 700; color: var(--text); text-align: center; line-height: 1.25; }

/* Flash deals */
.flash {
  background: linear-gradient(135deg, var(--red), var(--red-dark));
  border-radius: var(--radius); padding: 0.9rem; margin-top: 0.4rem;
}
.flash-head { display: flex; align-items: center; justify-content: space-between; color: #fff; margin-bottom: 0.7rem; }
.flash-head .fh-title { font-weight: 800; font-size: 1.1rem; }
.flash-head .fh-timer { background: rgba(0,0,0,0.25); border-radius: 8px; padding: 0.2rem 0.7rem; font-weight: 700; font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.flash-scroll { display: flex; gap: 0.6rem; overflow-x: auto; scrollbar-width: none; }
.flash-scroll::-webkit-scrollbar { display: none; }
.flash-card {
  min-width: 130px; max-width: 130px; background: #fff; border-radius: 10px; overflow: hidden;
  display: flex; flex-direction: column; cursor: pointer;
}
.flash-card img, .flash-card .fc-ph { width: 100%; aspect-ratio: 1; object-fit: cover; background: #f3f4f6; display: flex; align-items: center; justify-content: center; font-size: 2rem; }
.flash-card .fc-body { padding: 0.5rem; }
.flash-card .fc-name { font-size: 0.8rem; font-weight: 600; line-height: 1.3; height: 2.1em; overflow: hidden; }
.flash-card .fc-price { color: var(--red); font-weight: 800; font-size: 0.95rem; }
.flash-card .fc-old { color: var(--muted); font-size: 0.75rem; text-decoration: line-through; }
.discount-badge {
  position: absolute; top: 6px; right: 6px; background: var(--red); color: #fff;
  border-radius: 999px; padding: 0.1rem 0.5rem; font-size: 0.72rem; font-weight: 800;
}
.flash-card { position: relative; }

/* Product grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); gap: 0.7rem; padding-bottom: 2rem; }
.pcard {
  background: var(--card); border-radius: var(--radius); overflow: hidden;
  display: flex; flex-direction: column; position: relative;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.pcard-img { width: 100%; aspect-ratio: 1; object-fit: cover; background: #f3f4f6; display: block; cursor: pointer; }
.pcard-body { padding: 0.6rem; display: flex; flex-direction: column; gap: 0.2rem; flex: 1; }
.pcard-name { font-weight: 600; font-size: 0.9rem; line-height: 1.35; height: 2.7em; overflow: hidden; }
.pcard-seller { color: var(--muted); font-size: 0.75rem; }
.pcard-price { color: var(--red); font-weight: 800; font-size: 1.05rem; margin-top: auto; }
.pcard-old { color: var(--muted); font-size: 0.78rem; text-decoration: line-through; font-weight: 400; }
.pcard .add-btn {
  margin-top: 0.45rem; background: var(--green); color: #fff; border: none;
  border-radius: 999px; padding: 0.45rem; font-weight: 700; font-size: 0.88rem;
}
.pcard .add-btn:hover { background: var(--green-dark); }

.empty-state { text-align: center; color: var(--muted); padding: 3rem 1rem; }

/* Drawer (cart) */
.drawer-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 90;
  opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
.drawer {
  position: fixed; top: 0; bottom: 0; left: 0; width: min(420px, 92vw);
  background: var(--card); z-index: 100; transform: translateX(-105%);
  transition: transform 0.25s; display: flex; flex-direction: column;
  box-shadow: 4px 0 24px rgba(0,0,0,0.15);
}
.drawer.open { transform: translateX(0); }
.drawer-overlay.open { opacity: 1; pointer-events: auto; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 1rem; border-bottom: 1px solid var(--border); }
.drawer-head h2 { font-size: 1.15rem; }
.drawer-close { background: none; border: none; font-size: 1.5rem; color: var(--muted); }
.drawer-body { flex: 1; overflow-y: auto; padding: 1rem; }
.cart-row { display: flex; gap: 0.7rem; align-items: center; padding: 0.6rem 0; border-bottom: 1px solid var(--border); }
.cart-row img { width: 56px; height: 56px; border-radius: 8px; object-fit: cover; background: #f3f4f6; }
.cart-row .ci-name { font-weight: 600; font-size: 0.9rem; }
.cart-row .ci-price { color: var(--red); font-weight: 700; font-size: 0.9rem; }
.qty-ctl { display: flex; align-items: center; gap: 0.4rem; margin-right: auto; }
.qty-ctl button { width: 28px; height: 28px; border-radius: 8px; border: 1px solid var(--border); background: #fff; font-size: 1rem; }
.drawer-foot { border-top: 1px solid var(--border); padding: 1rem; }
.total-line { display: flex; justify-content: space-between; font-weight: 800; font-size: 1.1rem; margin-bottom: 0.8rem; }

.btn-primary {
  display: block; width: 100%; background: var(--green); color: #fff; border: none;
  border-radius: 999px; padding: 0.85rem; font-size: 1.05rem; font-weight: 800; text-align: center;
}
.btn-primary:hover { background: var(--green-dark); }
.btn-primary:disabled { background: #9ca3af; cursor: not-allowed; }
.btn-secondary {
  background: #fff; border: 1px solid var(--border); border-radius: 999px;
  padding: 0.6rem 1rem; font-weight: 700; color: var(--text);
}
.btn-danger { background: var(--red); color: #fff; border: none; border-radius: 999px; padding: 0.4rem 0.9rem; font-size: 0.85rem; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 110;
  display: none; align-items: center; justify-content: center; padding: 1rem;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--card); border-radius: var(--radius); width: 100%; max-width: 480px;
  max-height: 88vh; overflow-y: auto; padding: 1.2rem; position: relative;
}
.modal-close { position: absolute; top: 0.6rem; left: 0.8rem; background: none; border: none; font-size: 1.4rem; color: var(--muted); z-index: 2; }
.modal img.pimg { width: 100%; border-radius: 10px; aspect-ratio: 1; object-fit: cover; background: #f3f4f6; }
.modal h3 { margin: 0.7rem 0 0.2rem; }
.modal .p-price { color: var(--red); font-weight: 800; font-size: 1.2rem; }
.modal .p-old { color: var(--muted); text-decoration: line-through; font-size: 0.95rem; font-weight: 400; margin-right: 0.5rem; }
.modal .p-seller { color: var(--muted); font-size: 0.9rem; }
.modal .p-desc { margin: 0.6rem 0; color: #374151; white-space: pre-wrap; }

/* Forms / panels */
.panel { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.2rem; margin: 1rem 0; }
.msg { padding: 0.7rem 1rem; border-radius: 10px; margin: 0.7rem 0; font-size: 0.95rem; }
.msg.ok { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.msg.err { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.msg.info { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }

/* Tables (admin/seller) */
.tbl { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.tbl th, .tbl td { padding: 0.55rem 0.5rem; border-bottom: 1px solid var(--border); text-align: right; vertical-align: top; }
.tbl th { color: var(--muted); font-weight: 700; }
.badge { display: inline-block; padding: 0.15rem 0.6rem; border-radius: 999px; font-size: 0.78rem; font-weight: 700; }
.badge.new { background: #dbeafe; color: #1d4ed8; }
.badge.confirmed { background: #fef3c7; color: #b45309; }
.badge.delivered { background: #d1fae5; color: #047857; }
.badge.canceled { background: #fee2e2; color: #b91c1c; }
.badge.pending { background: #fef3c7; color: #b45309; }
.badge.approved { background: #d1fae5; color: #047857; }
.badge.rejected { background: #fee2e2; color: #b91c1c; }

/* Tabs */
.tabs { display: flex; gap: 0.4rem; border-bottom: 2px solid var(--border); margin: 1rem 0; overflow-x: auto; }
.tab {
  background: none; border: none; padding: 0.6rem 1.1rem; font-size: 1rem; font-weight: 700;
  color: var(--muted); border-bottom: 3px solid transparent; margin-bottom: -2px; white-space: nowrap;
}
.tab.active { color: var(--green); border-bottom-color: var(--green); }

/* Footer */
.site-footer { background: var(--green); color: #d9eddf; padding: 1.5rem 0; margin-top: 2.5rem; text-align: center; font-size: 0.9rem; border-top: 4px solid var(--red); }
.site-footer a { color: #fff; font-weight: 700; }

.auth-wrap { max-width: 420px; margin: 2rem auto; }
.auth-wrap h1 { text-align: center; margin-bottom: 0.3rem; color: var(--green-dark); }
.auth-wrap .sub { text-align: center; color: var(--muted); margin-bottom: 1rem; }

.order-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; margin-bottom: 0.8rem; }
.order-card .oc-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 0.4rem; }
.order-card .oc-code { font-weight: 800; }
.order-card .oc-meta { color: var(--muted); font-size: 0.85rem; margin: 0.3rem 0; }
.order-card ul { margin: 0.4rem 0; padding-right: 1.1rem; }
.status-select { width: auto; padding: 0.35rem 0.6rem; font-size: 0.85rem; }

@media (max-width: 640px) {
  .grid { grid-template-columns: repeat(2, 1fr); }
  .cat-grid { grid-template-columns: repeat(4, 1fr); }
  .hero h1 { font-size: 1.35rem; }
  .header-links a.hide-sm { display: none; }
  .logo span { display: none; }
}
