/* app.css — مشروع الحانوت (واجهة المستخدم) */

/* ألوان عامة */
:root {
  --main-green: #007c37;
  --main-yellow: #fecb56;
  --main-brown: #4e2e1e;
  --pill: #f6f6f6;
  --pill-border: #e7e7e7;
  --pill-active: #e9f7f0;
  --text: #222;
}

body {
  background: #fffef9;
}

/* شريط البحث (موبايل فقط) */
.big-search-bar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 30;
  background: #fff;
  padding: .75rem;
  border-bottom: 1px solid #eee;
  gap: .5rem;
  align-items: center;
}

/* احتياط إضافي: ملي الـoverlay مفتوح خبي الشريط */
body.cats-open .big-search-bar {
  display: none !important;
}

/* باش مانبقاش نشوف Scroll ونتفادى تحريك المحتوى */
body.cats-open {
  overflow: hidden !important;
  touch-action: none;
}

/* إخفاء زرّ المفضلة ملي تكون لائحة الفئات مفتوحة */
body.cats-open .fav-btn {
  display: none !important;
}

.big-search-bar .form-control {
  min-height: 52px;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding-inline: 1.2rem;
  font-size: 16px;
  background: var(--surface-2);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);
}

.big-search-bar .form-control:focus {
  border-color: var(--brand-2);
  box-shadow: 0 0 0 4px rgba(0, 168, 107, 0.15);
  background: #fff;
}

.big-search-bar input[type="search"]::-webkit-search-cancel-button,
.big-search-bar input[type="search"]::-webkit-search-decoration {
  -webkit-appearance: none;
}

.big-search-bar input[type="search"]::-ms-clear,
.big-search-bar input[type="search"]::-ms-reveal {
  display: none;
  width: 0;
  height: 0;
}

.big-search-bar .clear-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  border: 1px solid #ddd;
  background: #fafafa;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  user-select: none;
}

.big-search-bar.has-value .clear-btn {
  display: flex;
}

@media (max-width:991.98px) {
  .big-search-bar {
    display: flex !important;
  }
}

@media (min-width:992px) {
  .big-search-bar {
    display: none !important;
  }
}

@media (max-width:991.98px) {

  /* iOS Safari auto-zooms focused inputs smaller than 16px */
  .big-search-bar .form-control {
    font-size: 16px;
  }
}

/* شريط أقسام أفقي (اختياري) */
.cat-strip {
  display: flex;
  gap: .5rem;
  overflow: auto;
  white-space: nowrap;
  padding: .5rem .25rem;
  scroll-snap-type: x mandatory;
}

.cat-pill {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  background: var(--pill);
  color: #333;
  border: 1px solid var(--pill-border);
  border-radius: 999px;
  padding: .5rem .75rem;
  text-decoration: none;
  scroll-snap-align: center;
  user-select: none;
}

.cat-pill .icon-emoji {
  font-size: 18px;
  line-height: 1;
}

.cat-pill .icon-img {
  width: 20px;
  height: 20px;
  object-fit: contain;
}

.cat-pill.active {
  background: var(--pill-active);
  color: var(--main-green);
  border-color: #cfe9dd;
  font-weight: 600;
}

/* كروت المنتجات */
.product-card-container {
  padding: .5rem;
}

.card.product {
  border: 1px solid #eee;
  border-radius: 14px;
  overflow: hidden;
  transition: transform .12s ease;
}

.card.product:hover {
  transform: translateY(-2px);
}

.card.product img {
  height: 170px;
  object-fit: contain;
  background: #fff;
}

.card.product .card-title {
  font-size: .95rem;
  min-height: 2.5em;
}

.price {
  font-weight: 700;
  color: #1a1a1a;
}

.btn-add {
  background: var(--main-green);
  border: none;
}

.btn-add:hover {
  background: #066a32;
}

/* رسالة لا نتائج */
#no-results {
  color: #666;
}

/* يخبي أي عنصر معلّم بالـ hidden */
[hidden] {
  display: none !important;
}

/* ===== Cats Overlay (Fullscreen) ===== */
#cats-overlay {
  position: fixed;
  inset: 0;
  /* فوق أي حاجة بما فيها bottom-nav */
  z-index: 5000;
  display: none;
}

#cats-overlay.show {
  display: block;
}

.cats-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  opacity: 0;
  transition: opacity .25s ease;
}

#cats-overlay.show .cats-backdrop {
  opacity: 1;
}

/* Panel كامل الشاشة مع Slide-in */
.cats-panel {
  position: absolute;
  inset: 0;
  background: #fff;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform .28s ease;
  -webkit-overflow-scrolling: touch;
}

#cats-overlay.show .cats-panel {
  transform: none;
}

/* Header */
.cats-header {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--glass-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding: 16px 20px;
}

.cats-title {
  margin: 0;
  font-size: clamp(1.2rem, 1.1vw, 1.4rem);
  font-weight: 800;
  color: var(--brand-2);
}


/* لائحة الفئات */
.cats-list {
  flex: 1;
  overflow: auto;
  padding: 8px 0;
}

.cats-item {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 60px;
  padding: 14px 20px;
  text-decoration: none;
  color: var(--ink);
  border-bottom: 1px solid var(--border);
  width: 100%;
  box-sizing: border-box;
  transition: background var(--transition-fast);
}

.cats-item:active {
  background: var(--pill);
}

.cats-item.active {
  background: var(--pill-active);
  color: var(--brand-2);
}

.cats-icon {
  width: 36px;
  height: 36px;
  object-fit: contain;
  flex: 0 0 36px;
  border-radius: 10px;
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.cats-emoji {
  font-size: 24px;
  line-height: 1;
  width: 36px;
  text-align: center;
}

.cats-name {
  flex: 1;
  font-size: clamp(1rem, .2vw + .95rem, 1.08rem);
  font-weight: 700;
}

.cats-chev {
  color: var(--muted);
  font-size: 1.1rem;
  transition: transform var(--transition-fast);
}

.cats-item:hover .cats-chev {
  transform: translateX(3px);
}

html[dir="rtl"] .cats-item:hover .cats-chev {
  transform: translateX(-3px);
}



/* ===== Sub-categories (مخفية حتى الضغط على Parent) ===== */
button.cats-item {
  width: 100%;
  background: transparent;
  border: 0;
  text-align: inherit;
}

.cats-group {
  border-bottom: 1px solid #f2f2f2;
}

.cats-group>.cats-item {
  border-bottom: 0;
}

.cats-sublist {
  display: block;
  padding: 0 0 8px 0;
}

.cats-sublist[hidden] {
  display: none !important;
}

.cats-subitem {
  padding-top: 11px;
  padding-bottom: 11px;
  border-bottom: 0;
  padding-inline-start: 56px;
  /* indention (نفس اصطفاف لائحة الأول) */
}

.cats-subdot {
  color: #3aa76d;
  font-weight: 800;
}

/* السهم فـ Parent فقط: أيقونة Bootstrap مع دوران */
.cats-arrow {
  color: var(--muted);
  font-size: 14px;
  width: 24px;
  height: 24px;
  display: flex !important;
  align-items: center;
  justify-content: center;
  transition: transform var(--transition-smooth);
}

.cats-arrow::before {
  font-family: "bootstrap-icons";
  content: "\F285";
  /* bi-chevron-right */
  font-weight: 800;
}

html[dir="rtl"] .cats-arrow::before {
  content: "\F284";
  /* bi-chevron-left */
}

.cats-group.open .cats-arrow {
  transform: rotate(90deg);
}

html[dir="rtl"] .cats-group.open .cats-arrow {
  transform: rotate(-90deg);
}


/* إحساس clickable */
.cats-parent-btn {
  cursor: pointer;
}

/* شوية تحسين فالديسكتوب */
@media (min-width: 992px) {
  .cats-panel {
    max-width: 480px;
    width: min(480px, 92vw);
    margin: 0;
    left: auto;
    right: 0;
    border: 1px solid #eee;
    border-radius: 16px;
  }
}

/* ===== خلي bottom-nav فوق الفئات، وقطع overlay من التحت ===== */
:root {
  --bn-h: 64px;
}

/* قيمة افتراضية، JS غيحدّثها حسب القياس الحقيقي */

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 2147483647;
  /* أعلى من أي شي */
}

/* overlay ما يغطيش منطقة الناف */
#cats-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  /* ✅ نحترمو علُوّ الناف */
}

#cats-overlay .cats-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: var(--bn-h);
  /* حتى الخلفية متغطّيش الناف */
}

#cats-overlay .cats-panel {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: var(--bn-h);
  /* البانيل ما يهبطش تحت الناف */
  padding-bottom: calc(var(--bn-h) + env(safe-area-inset-bottom));
}

/* فالديسكتوب الناف مخفي، خليه ياخذ الشاشة كاملة */
@media (min-width: 992px) {
  :root {
    --bn-h: 0px;
  }
}

@media (max-width: 360px) {
  .big-search-bar {
    padding: .6rem .55rem;
    gap: .4rem;
  }

  .big-search-bar .form-control {
    min-height: 46px;
  }

  .big-search-bar .clear-btn {
    width: 46px;
    height: 46px;
  }
}