/* ===========================================
   الطاهرة - بيت المكسرات
   هوية بصرية: بني كراميل دافئ يناسب طبيعة المنتجات
   =========================================== */

:root {
  --brand: #8a4b2e;        /* بني كراميل غامق - اللون الأساسي */
  --brand-light: #c98a52;  /* بني فاتح/عسلي - أزرار وتمييز */
  --accent: #e8a33d;       /* لمسة ذهبية للتخفيضات والعروض */
  --bg: #fbf7f2;           /* خلفية كريمية دافئة */
  --card-bg: #ffffff;
  --text: #2b1d14;
  --text-muted: #8a7a6d;
  --border: #ece3d8;
  --danger: #c0392b;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(43, 29, 20, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", "Tahoma", "Cairo", sans-serif;
  background: var(--bg);
  color: var(--text);
  direction: rtl;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  position: relative;
  padding-bottom: 80px;
}

/* ---------- Topbar ---------- */
.topbar {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-light) 100%);
  color: #fff;
  padding: 18px 20px 24px;
  border-radius: 0 0 22px 22px;
}

.topbar h1 {
  margin: 0 0 4px;
  font-size: 22px;
  font-weight: 700;
}

.topbar p {
  margin: 0 0 14px;
  font-size: 14px;
  opacity: 0.9;
}

.search-box {
  background: #fff;
  border-radius: 999px;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 14px;
  box-shadow: var(--shadow);
}

.search-box input {
  border: none;
  outline: none;
  flex: 1;
  font-size: 14px;
  background: transparent;
  color: var(--text);
  text-align: right;
}

.back-btn {
  background: rgba(255,255,255,0.2);
  border: none;
  color: #fff;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
  margin-bottom: 10px;
}

/* ---------- Page content ---------- */
#page-content {
  padding: 18px 16px 90px;
}

.section-title {
  font-size: 17px;
  font-weight: 700;
  margin: 18px 0 12px;
  color: var(--text);
}

/* ---------- Categories row ---------- */
.categories-row {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 6px;
}

.category-pill {
  flex: 0 0 auto;
  text-align: center;
  cursor: pointer;
  width: 78px;
}

.category-pill .circle {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--card-bg);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  margin: 0 auto 6px;
  transition: border-color .15s;
}

.category-pill:hover .circle,
.category-pill.active .circle {
  border-color: var(--brand-light);
}

.category-pill span.label {
  font-size: 12.5px;
  color: var(--text);
  line-height: 1.3;
  display: block;
}

/* ---------- Featured card ---------- */
.featured-card {
  background: linear-gradient(135deg, var(--brand-light), var(--brand));
  border-radius: var(--radius);
  padding: 18px;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
}

.featured-card .emoji {
  font-size: 44px;
}

.featured-card h3 {
  margin: 0 0 4px;
  font-size: 16px;
}

.featured-card .price {
  font-weight: 700;
}

/* ---------- Product grid ---------- */
.product-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.product-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: var(--shadow);
  position: relative;
  cursor: pointer;
}

.product-card .thumb {
  height: 92px;
  border-radius: 10px;
  background: #f1e6d8;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
  margin-bottom: 10px;
  position: relative;
  overflow: hidden;
}

.product-card .out-of-stock-overlay {
  position: absolute;
  inset: 0;
  background: rgba(43,29,20,0.55);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  border-radius: 10px;
}

.add-btn {
  position: absolute;
  bottom: 10px;
  left: 10px;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--bg);
  border: 1.5px solid var(--brand-light);
  color: var(--brand);
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.product-card .name {
  font-size: 13.5px;
  font-weight: 600;
  margin: 0 0 4px;
  min-height: 34px;
}

.product-card .price-row {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--brand);
}

.product-card .price-row .original {
  text-decoration: line-through;
  color: var(--text-muted);
  font-weight: 400;
  font-size: 12px;
  margin-inline-start: 6px;
}

/* ---------- Product detail ---------- */
.product-detail-img {
  height: 220px;
  border-radius: var(--radius);
  background: #f1e6d8;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 70px;
  margin-bottom: 16px;
}

.product-detail h2 {
  margin: 0 0 6px;
  font-size: 20px;
}

.product-detail .price {
  color: var(--brand);
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 14px;
}

.product-detail .desc {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.7;
  margin-bottom: 20px;
}

.variant-options label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  margin-bottom: 10px;
  cursor: pointer;
  font-size: 14px;
}

.variant-options label.selected {
  border-color: var(--brand-light);
  background: #fdf3e7;
}

.variant-options input { accent-color: var(--brand); }

.sticky-add-bar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  background: #fff;
  border-top: 1px solid var(--border);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 -2px 12px rgba(0,0,0,0.06);
}

.qty-stepper {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 6px 10px;
}

.qty-stepper button {
  border: none;
  background: none;
  font-size: 18px;
  color: var(--brand);
  cursor: pointer;
  width: 24px;
}

.btn-primary {
  flex: 1;
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 13px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

.btn-primary:disabled {
  background: #ccc;
  cursor: not-allowed;
}

/* ---------- Cart / Orders ---------- */
.cart-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.cart-line .meta { color: var(--text-muted); font-size: 12.5px; }

.cart-summary-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 14px;
}

.cart-summary-row.total {
  font-weight: 700;
  font-size: 16px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
  margin-top: 6px;
}

.free-delivery-note {
  background: #fdf3e7;
  color: var(--brand);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 12.5px;
  margin: 12px 0;
}

/* ---------- Profile ---------- */
.profile-header {
  text-align: center;
  padding: 10px 0 20px;
}

.profile-header .avatar {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: var(--brand-light);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  margin: 0 auto 10px;
}

.list-group {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 18px;
}

.list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  cursor: pointer;
}

.list-item:last-child { border-bottom: none; }
.list-item .chev { color: var(--text-muted); }
.list-item.danger { color: var(--danger); font-weight: 600; }

.group-label {
  font-size: 13px;
  color: var(--text-muted);
  margin: 6px 4px;
}

/* ---------- Bottom nav ---------- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  background: var(--brand);
  border-radius: 20px 20px 0 0;
  display: flex;
  justify-content: space-around;
  padding: 10px 0 calc(10px + env(safe-area-inset-bottom));
  z-index: 20;
}

.nav-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,0.65);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 11.5px;
  cursor: pointer;
}

.nav-btn.active { color: #fff; }
.nav-btn .icon { font-size: 19px; }

/* ---------- Cart FAB ---------- */
.cart-fab {
  position: fixed;
  bottom: 78px;
  left: 50%;
  transform: translateX(-50%);
  max-width: 440px;
  width: calc(100% - 32px);
  background: var(--text);
  color: #fff;
  border-radius: 12px;
  padding: 13px 18px;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  z-index: 15;
  box-shadow: var(--shadow);
}

.hidden { display: none !important; }

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 60px 20px;
  font-size: 14px;
}

.badge-out {
  display: inline-block;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 6px;
  margin-inline-start: 6px;
}

.toast {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: #fff;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 13px;
  z-index: 50;
  opacity: 0;
  transition: opacity .2s;
}

.toast.show { opacity: 1; }
