/* ── Variables ──────────────────────────────────────────────────────────── */
:root {
  --navy:       #1a2744;
  --navy-dark:  #111b33;
  --navy-light: #253460;
  --orange:     #f05a28;
  --orange-h:   #d94e20;
  --white:      #ffffff;
  --bg:         #f7f8fa;
  --border:     #e4e7ee;
  --text:       #1a1f36;
  --muted:      #6b7280;
  --radius:     8px;
  --shadow-sm:  0 1px 3px rgba(0,0,0,.08);
  --shadow-md:  0 4px 16px rgba(0,0,0,.12);
  --font-latin: 'Inter', system-ui, sans-serif;
  --font-arabic:'Cairo', system-ui, sans-serif;
}

/* ── Reset & base ───────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
button { color: inherit; font-size: inherit; line-height: inherit; appearance: none; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-latin);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

body.rtl {
  font-family: var(--font-arabic);
  direction: rtl;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
}

/* ── Navbar ─────────────────────────────────────────────────────────────── */
.navbar {
  background: var(--navy);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}

.navbar__inner {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 56px;
}

.navbar__logo {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--white);
  letter-spacing: -.5px;
  white-space: nowrap;
  flex-shrink: 0;
}
.navbar__logo:hover { color: var(--orange); }

.navbar__search {
  flex: 1;
  display: flex;
  max-width: 520px;
}

.navbar__search-input {
  flex: 1;
  padding: 8px 14px;
  border: none;
  border-radius: var(--radius) 0 0 var(--radius);
  font-size: .95rem;
  outline: none;
  background: rgba(255,255,255,.12);
  color: var(--white);
}
.navbar__search-input::placeholder { color: rgba(255,255,255,.5); }
.navbar__search-input:focus { background: rgba(255,255,255,.2); }

.rtl .navbar__search-input {
  border-radius: 0 var(--radius) var(--radius) 0;
}

.navbar__search-btn {
  padding: 0 14px;
  background: var(--orange);
  border: none;
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--white);
  cursor: pointer;
  display: flex;
  align-items: center;
}
.navbar__search-btn:hover { background: var(--orange-h); }

.rtl .navbar__search-btn {
  border-radius: var(--radius) 0 0 var(--radius);
}

.navbar__links {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-inline-start: auto;
}

.lang-switch {
  color: rgba(255,255,255,.8);
  font-size: .85rem;
  font-weight: 600;
  padding: 4px 10px;
  border: 1px solid rgba(255,255,255,.3);
  border-radius: 20px;
  transition: .2s;
}
.lang-switch:hover { color: var(--white); border-color: var(--white); }

.navbar__icon-btn {
  color: rgba(255,255,255,.8);
  display: flex;
  align-items: center;
  position: relative;
  padding: 4px;
}
.navbar__icon-btn:hover { color: var(--white); }

.fav-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--orange);
  color: var(--white);
  font-size: .65rem;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
}

/* ── Category nav ───────────────────────────────────────────────────────── */
.cat-nav {
  background: var(--navy-light);
  border-bottom: 1px solid var(--navy-dark);
}

.cat-nav__inner {
  display: flex;
  gap: 4px;
  height: 40px;
  align-items: center;
}

.cat-nav__item {
  color: rgba(255,255,255,.75);
  font-size: .875rem;
  font-weight: 500;
  padding: 4px 14px;
  border-radius: 20px;
  white-space: nowrap;
  transition: .15s;
}
.cat-nav__item:hover { color: var(--white); background: rgba(255,255,255,.1); }
.cat-nav__item--active { color: var(--white); background: var(--orange); }

/* Category dropdown */
.cat-dropdown {
  position: relative;
  display: inline-flex;
  align-items: center;
  align-self: stretch;
}
.cat-dropdown__toggle {
  color: rgba(255,255,255,.75);
  font-size: .875rem;
  font-weight: 500;
  padding: 4px 14px;
  border-radius: 20px;
  white-space: nowrap;
  transition: .15s;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: inherit;
}
.cat-dropdown__toggle:hover,
.cat-dropdown:hover .cat-dropdown__toggle { color: var(--white); background: rgba(255,255,255,.1); }
.cat-dropdown--active .cat-dropdown__toggle { color: var(--white); background: var(--orange); }
.cat-dropdown__arrow { font-size: .65rem; opacity: .7; transition: transform .2s; }
.cat-dropdown:hover .cat-dropdown__arrow { transform: rotate(180deg); }
.cat-dropdown__menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background: var(--navy-dark);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  min-width: 180px;
  z-index: 200;
  padding: 4px 0;
}
.rtl .cat-dropdown__menu { left: auto; right: 0; }
.cat-dropdown:hover .cat-dropdown__menu { display: block; }
.cat-dropdown__menu a {
  display: block;
  padding: 8px 16px;
  color: rgba(255,255,255,.8);
  font-size: .875rem;
  transition: .15s;
}
.cat-dropdown__menu a:hover { color: var(--white); background: rgba(255,255,255,.08); }

/* ── Main content ───────────────────────────────────────────────────────── */
.main-content {
  flex: 1;
  padding: 24px 0 40px;
}

/* ── Product Grid ───────────────────────────────────────────────────────── */
.product-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}

.product-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: box-shadow .2s, transform .2s;
  display: flex;
  flex-direction: column;
  position: relative;
}
.product-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.product-card__img-wrap {
  aspect-ratio: 1;
  background: #f0f2f6;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.product-card__img { width: 100%; height: 100%; object-fit: cover; }

.product-card__body {
  padding: 12px 14px 14px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.product-card__brand {
  font-size: .75rem;
  color: var(--muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .4px;
  cursor: pointer;
  text-decoration: none;
}

.product-card__name {
  font-size: .9rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text);
}

.product-card__spec {
  font-size: .8rem;
  color: var(--muted);
}

.product-card__price-row {
  margin-top: auto;
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.price--best {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--orange);
}

.price--original {
  font-size: .82rem;
  color: var(--muted);
  text-decoration: line-through;
}

.price--stores {
  font-size: .78rem;
  color: var(--muted);
  margin-inline-start: auto;
}

.product-card__stretched-link {
  display: none;
}

.fav-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: var(--muted);
  margin-inline-start: auto;
}
.fav-btn:hover, .fav-btn.active { color: var(--orange); }

/* ── Price comparison table ─────────────────────────────────────────────── */
.price-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--white);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.price-table th {
  background: var(--navy);
  color: var(--white);
  padding: 10px 14px;
  font-size: .85rem;
  text-align: start;
}
.price-table td {
  padding: 10px 14px;
  font-size: .9rem;
  border-bottom: 1px solid var(--border);
}
.price-table tr:last-child td { border-bottom: none; }
.price-table tr:hover td { background: #f9fafc; }

.price-table .best-row td { background: #fff8f5; }
.price-table .best-price { color: var(--orange); font-weight: 700; }

.btn-buy {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 16px;
  background: var(--orange);
  color: var(--white);
  border-radius: var(--radius);
  font-size: .85rem;
  font-weight: 600;
  transition: background .15s;
}
.btn-buy:hover { background: var(--orange-h); }

/* ── Search page ────────────────────────────────────────────────────────── */
.search-header {
  margin-bottom: 20px;
}
.search-header h1 {
  font-size: 1.25rem;
  font-weight: 600;
}
.search-header .result-count {
  font-size: .9rem;
  color: var(--muted);
}

/* ── Hero (home) ─────────────────────────────────────────────────────────── */
.hero {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%);
  color: var(--white);
  padding: 48px 0;
  margin-bottom: 32px;
}
.hero h1 {
  font-size: clamp(1.5rem, 3vw, 2.4rem);
  font-weight: 700;
  margin-bottom: 12px;
}
.hero p {
  font-size: 1.05rem;
  color: rgba(255,255,255,.8);
  max-width: 540px;
}

/* ── Section headings ───────────────────────────────────────────────────── */
.section-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--orange);
  display: inline-block;
}

/* ── Footer ─────────────────────────────────────────────────────────────── */
.footer {
  background: var(--navy-dark);
  color: rgba(255,255,255,.65);
  padding: 24px 0;
  margin-top: auto;
}

.footer__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.footer__copy { font-size: .85rem; }

.footer__links {
  display: flex;
  gap: 16px;
  font-size: .85rem;
}
.footer__links a:hover { color: var(--white); }

/* ── Utility ─────────────────────────────────────────────────────────────── */
.text-muted  { color: var(--muted); }
.text-orange { color: var(--orange); }
.mt-4  { margin-top: 1rem; }
.mb-4  { margin-bottom: 1rem; }
.empty-state {
  text-align: center;
  padding: 60px 0;
  color: var(--muted);
}
.empty-state p { font-size: 1rem; }

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .navbar__inner { gap: 10px; }
  .navbar__logo  { font-size: 1.2rem; }
  .hero { padding: 32px 0; }
  .product-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
}

/* ── Cat-nav divider ─────────────────────────────────────────────────────── */
.cat-nav__divider {
  width: 1px;
  height: 20px;
  background: rgba(255,255,255,.2);
  flex-shrink: 0;
  margin: 0 4px;
}

/* ── Section header ──────────────────────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 16px;
}
.section-header .section-title { margin-bottom: 0; }
.section-more {
  font-size: .875rem;
  color: var(--orange);
  font-weight: 600;
  white-space: nowrap;
}
.section-more:hover { color: var(--orange-h); }

/* ── Drop badge ──────────────────────────────────────────────────────────── */
.product-card__img-wrap { position: relative; }
.drop-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: var(--orange);
  color: var(--white);
  font-size: .72rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
  z-index: 1;
}
.rtl .drop-badge { left: auto; right: 8px; }

/* ── Pagination ──────────────────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 32px;
  padding-bottom: 8px;
}
.pagination__btn {
  padding: 6px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .875rem;
  font-weight: 500;
  background: var(--white);
  color: var(--text);
  transition: .15s;
}
.pagination__btn:hover { border-color: var(--orange); color: var(--orange); }
.pagination__btn--disabled {
  color: var(--muted);
  cursor: default;
  pointer-events: none;
}
.pagination__info {
  font-size: .875rem;
  color: var(--muted);
}

/* ── Image Search Modal ────────────────────────────────────────────────────── */
.navbar__picsearch-btn {
  margin: 0 4px;
  flex-shrink: 0;
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  z-index: 9999;
  display: none;
}
.modal-overlay.is-open {
  display: block;
}
.modal-overlay .modal-wrapper {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #ffffff;
  border-radius: 12px;
  width: 90%;
  max-width: 480px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  overflow: hidden;
}
.modal-overlay .modal-header {
  padding: 20px 24px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-overlay .modal-header h3 {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
}
.modal-overlay .modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #6b7280;
  padding: 0 4px;
  line-height: 1;
}
.modal-overlay .modal-close:hover { color: #1a1f36; }

.modal-overlay .modal-tabs {
  display: flex;
  padding: 16px 24px 0;
  border-bottom: 1px solid #e4e7ee;
}
.modal-overlay .modal-tab {
  padding: 10px 20px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  font-size: 14px;
  font-weight: 500;
  color: #6b7280;
  cursor: pointer;
  margin-bottom: -1px;
}
.modal-overlay .modal-tab:hover { color: #1a1f36; }
.modal-overlay .modal-tab.active {
  color: #f05a28;
  border-bottom-color: #f05a28;
}

.modal-overlay .modal-body {
  padding: 24px;
}
.modal-overlay .modal-tab-content {
  display: none;
}
.modal-overlay .modal-tab-content.active {
  display: block;
}

.modal-overlay .picsearch-upload-area {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}
.modal-overlay .picsearch-upload-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 40px 24px;
  border: 2px dashed #e4e7ee;
  border-radius: 8px;
  cursor: pointer;
  width: 100%;
  min-height: 180px;
  text-align: center;
  color: #6b7280;
  font-size: 15px;
  background: #fafbfc;
}
.modal-overlay .picsearch-upload-label:hover {
  border-color: #f05a28;
  color: #f05a28;
  background: #fff8f5;
}
.modal-overlay .picsearch-upload-label.has-file {
  border-color: #f05a28;
  background: #fff8f5;
}
.modal-overlay .picsearch-upload-label input[type="file"] {
  display: none;
}
.modal-overlay .picsearch-upload-label svg {
  flex-shrink: 0;
}

.modal-overlay .picsearch-url-input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #e4e7ee;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 16px;
  box-sizing: border-box;
}
.modal-overlay .picsearch-url-input:focus {
  outline: none;
  border-color: #f05a28;
  box-shadow: 0 0 0 2px rgba(240,90,40,0.15);
}

.modal-overlay .picsearch-submit {
  width: 100%;
  padding: 12px;
  font-size: 15px;
  font-weight: 600;
  background: #f05a28;
  color: #ffffff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}
.modal-overlay .picsearch-submit:hover {
  background: #d94e20;
}

/* ── Image Search Query Thumbnail ──────────────────────────────────────────── */
.picsearch-query {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 16px;
}
.picsearch-query img {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid #e4e7ee;
  flex-shrink: 0;
  display: block;
}

/* ── RTL Image Search Modal ────────────────────────────────────────────────── */
.rtl .modal-overlay .modal-header { direction: rtl; }
.rtl .modal-overlay .modal-tabs { direction: rtl; }
.rtl .modal-overlay .picsearch-upload-label { direction: rtl; }

/* ── Price Table Thumbnail ─────────────────────────────────────────────────── */
.price-thumb {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform .15s;
}
.price-thumb:hover {
  transform: scale(1.1);
  border-color: var(--orange);
}

/* ── Image Lightbox ────────────────────────────────────────────────────────── */
.img-lightbox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.75);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.img-lightbox img {
  max-width: 90%;
  max-height: 90%;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.4);
  cursor: default;
}

/* ── Price Sort ────────────────────────────────────────────────────────────── */
.price-sort {
  display: inline-flex;
  flex-direction: column;
  gap: 0;
  margin-inline-start: 6px;
  vertical-align: middle;
  line-height: 1;
}
.price-sort__btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: .55rem;
  padding: 0 2px;
  color: rgba(255,255,255,.45);
  line-height: 1.1;
  transition: color .15s;
}
.price-sort__btn:hover { color: var(--white); }

/* ── Best Badge ────────────────────────────────────────────────────────────── */
.best-badge {
  display: inline-block;
  background: var(--orange);
  color: var(--white);
  font-size: .7rem;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 10px;
  margin-inline-start: 8px;
  vertical-align: middle;
  letter-spacing: .3px;
}
