:root {
  --ink: #172033;
  --muted: #6b7280;
  --cream: #f7f7f5;
  --white: #ffffff;
  --orange: #f97316;
  --orange-dark: #ea580c;
  --green: #16a34a;
  --line: #e8e8e4;
  --shadow: 0 16px 45px rgba(23, 32, 51, 0.10);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--cream);
  color: var(--ink);
  font-family: "Tajawal", sans-serif;
}

button, input, textarea { font: inherit; }
button { cursor: pointer; }

.topbar {
  height: 76px;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 24px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  font-size: 22px;
  font-weight: 800;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: var(--orange);
  color: white;
}
.whatsapp-contact {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 230px;
  min-height: 58px;
  color: var(--ink);
  text-decoration: none;
  border: 2px solid #22c55e;
  background: #ffffff;
  border-radius: 14px;
  padding: 8px 18px;
  direction: rtl;
  box-shadow: 0 8px 24px rgba(34, 197, 94, 0.14);
}
.whatsapp-contact span { color: #15803d; font-size: 13px; font-weight: 800; }
.whatsapp-contact strong { direction: ltr; font-size: 18px; }
#adminButton { justify-self: end; }

.ghost-button, .danger-ghost {
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
  border-radius: 12px;
  padding: 10px 16px;
  font-weight: 700;
}

.hero {
  max-width: 1132px;
  min-height: 320px;
  margin: 20px auto 56px;
  padding: 64px 72px;
  border-radius: 28px;
  background:
    linear-gradient(105deg, rgba(15, 23, 42, 0.94), rgba(15, 23, 42, 0.72)),
    url("https://images.unsplash.com/photo-1441986300917-64674bd600d8?auto=format&fit=crop&w=1600&q=80") center/cover;
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  overflow: hidden;
}

.hero h1 { font-size: clamp(38px, 5vw, 64px); margin: 10px 0 12px; line-height: 1.1; }
.hero p { max-width: 520px; color: #dfe4ec; font-size: 19px; }
.eyebrow { color: var(--orange); font-size: 13px; font-weight: 800; letter-spacing: 0.5px; }
.hero-badge {
  width: 135px;
  height: 135px;
  flex: 0 0 auto;
  display: grid;
  place-content: center;
  text-align: center;
  border: 2px solid rgba(255,255,255,.7);
  border-radius: 50%;
  transform: rotate(-7deg);
  background: rgba(249,115,22,.9);
  font-size: 16px;
}
.hero-badge strong { font-size: 30px; }

.catalog-section { max-width: 1132px; margin: 0 auto 80px; padding: 0 24px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; margin-bottom: 24px; }
.section-heading h2 { margin: 5px 0 0; font-size: 32px; }
.count-badge { background: white; border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; color: var(--muted); }

.product-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px; }
.product-card {
  background: white;
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 5px 20px rgba(23,32,51,.03);
  transition: transform .2s, box-shadow .2s;
}
.product-card:hover { transform: translateY(-4px); box-shadow: var(--shadow); }
.product-image { position: relative; aspect-ratio: 4/3; background: #ecece8; overflow: hidden; }
.product-image img { width: 100%; height: 100%; object-fit: cover; }
.status {
  position: absolute;
  top: 12px;
  right: 12px;
  border-radius: 999px;
  padding: 7px 11px;
  background: var(--green);
  color: white;
  font-size: 12px;
  font-weight: 800;
}
.status.sold { background: #64748b; }
.product-content { padding: 18px; }
.product-content h3 { margin: 0 0 8px; font-size: 20px; }
.product-content p { min-height: 44px; margin: 0 0 16px; color: var(--muted); line-height: 1.5; }
.product-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.price { font-size: 21px; font-weight: 800; color: var(--orange-dark); }
.primary-button {
  border: 0;
  border-radius: 11px;
  background: var(--orange);
  color: white;
  padding: 12px 18px;
  font-weight: 800;
}
.primary-button:hover { background: var(--orange-dark); }
.primary-button:disabled { background: #cbd5e1; cursor: not-allowed; }

.empty-state { text-align: center; background: white; border: 1px dashed #d7d7d1; border-radius: 18px; padding: 50px; }

.modal[hidden] { display: none; }
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(15,23,42,.62); backdrop-filter: blur(5px); }
.modal-panel {
  position: relative;
  width: min(560px, 100%);
  max-height: 92vh;
  overflow-y: auto;
  background: white;
  border-radius: 22px;
  padding: 28px;
  box-shadow: 0 30px 80px rgba(0,0,0,.25);
}
.modal-close { position: absolute; left: 18px; top: 14px; width: 36px; height: 36px; border: 0; border-radius: 50%; background: #f1f1ed; font-size: 24px; }
.modal-panel h2 { margin: 5px 0 18px; }
form label { display: block; margin-bottom: 14px; font-weight: 700; }
form label span { color: var(--muted); font-weight: 400; }
input, textarea {
  width: 100%;
  margin-top: 7px;
  border: 1px solid #deded8;
  border-radius: 10px;
  background: white;
  padding: 12px 13px;
  outline: none;
  resize: vertical;
}
input:focus, textarea:focus { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(249,115,22,.12); }
.order-product { display: flex; gap: 12px; align-items: center; background: var(--cream); border-radius: 12px; padding: 10px; margin-bottom: 16px; }
.order-product img { width: 66px; height: 66px; border-radius: 8px; object-fit: cover; }
.order-product strong { display: block; }
.order-product span { color: var(--orange-dark); font-weight: 800; }
.login-form { max-width: 380px; }
.hint { color: var(--muted); font-size: 13px; }

.admin-panel { width: min(760px, 100%); }
.dashboard-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.danger-ghost { color: #dc2626; }
.product-form { background: var(--cream); border-radius: 14px; padding: 16px; margin-bottom: 20px; }
.settings-form {
  background: #effaf3;
  border: 1px solid #bbf7d0;
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 20px;
}
.settings-form h3 { margin: 0 0 12px; }
.form-row { display: grid; grid-template-columns: 2fr 1fr; gap: 12px; }
.image-preview-wrap {
  height: 150px;
  margin-bottom: 14px;
  display: grid;
  place-items: center;
  border: 1px dashed #d3d3cd;
  border-radius: 12px;
  background: white;
  overflow: hidden;
  color: var(--muted);
}
.image-preview-wrap img {
  width: 100%;
  height: 150px;
  margin: 0;
  border: 0;
  border-radius: 0;
  object-fit: cover;
  display: none;
}
.image-preview-wrap img.visible { display: block; }
.image-preview-list {
  min-height: 100px;
  margin-bottom: 14px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 8px;
  border: 1px dashed #d3d3cd;
  border-radius: 12px;
  background: white;
}
.image-preview-list img { width: 100%; height: 84px; margin: 0; border-radius: 8px; object-fit: cover; }
.image-preview-empty { grid-column: 1 / -1; align-self: center; text-align: center; color: var(--muted); }
.free-delivery {
  margin: 12px 0;
  color: #15803d;
  background: #effaf3;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
  font-weight: 800;
}
.product-thumbnails {
  display: flex;
  gap: 6px;
  padding: 8px 12px 0;
  direction: rtl;
}
.product-thumbnails button {
  width: 54px;
  height: 54px;
  padding: 2px;
  border: 2px solid transparent;
  border-radius: 8px;
  background: white;
  overflow: hidden;
}
.product-thumbnails button.active { border-color: var(--orange); }
.product-thumbnails img { width: 100%; height: 100%; border-radius: 5px; object-fit: cover; }
.check-label { display: flex; align-items: center; gap: 8px; }
.check-label input { width: 18px; height: 18px; margin: 0; }
.form-actions { display: flex; gap: 8px; }
.admin-product-list { display: grid; gap: 8px; }
.admin-product-row { display: grid; grid-template-columns: 48px 1fr auto auto; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 11px; padding: 8px; }
.admin-product-row img { width: 48px; height: 48px; border-radius: 8px; object-fit: cover; }
.admin-product-row strong { display: block; }
.admin-product-row small { color: var(--muted); }
.row-actions { display: flex; gap: 6px; }
.row-actions button { border: 1px solid var(--line); background: white; border-radius: 8px; padding: 8px 10px; }
.row-actions .sold-toggle { color: var(--green); }
.row-actions .delete { color: #dc2626; }

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 100;
  transform: translateY(100px);
  opacity: 0;
  background: var(--ink);
  color: white;
  border-radius: 12px;
  padding: 13px 18px;
  box-shadow: var(--shadow);
  transition: .25s;
}
.toast.show { transform: translateY(0); opacity: 1; }
footer { border-top: 1px solid var(--line); text-align: center; color: var(--muted); padding: 24px; }

@media (max-width: 900px) {
  .hero { margin-inline: 24px; padding: 48px 36px; }
  .product-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
  .topbar { height: auto; min-height: 112px; padding: 10px 16px; grid-template-columns: 1fr auto; gap: 8px; }
  .whatsapp-contact { grid-column: 1 / -1; grid-row: 2; min-width: 0; width: 100%; min-height: 54px; padding: 6px 12px; }
  .whatsapp-contact strong { font-size: 17px; }
  #adminButton { grid-column: 2; grid-row: 1; padding: 9px 10px; font-size: 13px; }
  .hero { min-height: 280px; margin: 8px 16px 40px; padding: 36px 24px; }
  .hero-badge { display: none; }
  .hero h1 { font-size: 38px; }
  .catalog-section { padding-inline: 16px; }
  .product-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .admin-product-row { grid-template-columns: 48px 1fr; }
  .row-actions { grid-column: 1 / -1; }
  .modal { padding: 10px; align-items: end; }
  .modal-panel { max-height: 94vh; border-radius: 20px 20px 12px 12px; padding: 24px 18px; }
  .toast { right: 16px; left: 16px; text-align: center; }
}
