@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@300;400;500;700;900&display=swap');

:root {
  --color-bg: #faf7f2;
  --color-surface: #ffffff;
  --color-primary: #8b5e3c;
  --color-primary-dark: #6b4527;
  --color-accent: #c9a24b;
  --color-text: #2b241f;
  --color-text-light: #6f665d;
  --color-border: #ece5db;
  --color-danger: #c0392b;
  --color-success: #2e7d4f;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(43, 36, 31, 0.08);
  --shadow-hover: 0 10px 32px rgba(43, 36, 31, 0.14);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: 'Tajawal', sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  direction: rtl;
  text-align: right;
  line-height: 1.7;
}

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

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ===== Header ===== */
.site-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  gap: 20px;
}
.logo {
  font-size: 24px;
  font-weight: 900;
  color: var(--color-primary-dark);
  letter-spacing: -0.5px;
}
.logo span { color: var(--color-accent); }

.nav-links {
  display: flex;
  gap: 28px;
  font-weight: 500;
}
.nav-links a { transition: color .2s; }
.nav-links a:hover { color: var(--color-primary); }

.search-form {
  display: flex;
  align-items: center;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 6px 6px 6px 16px;
  flex: 1;
  max-width: 340px;
}
.search-form input {
  border: none;
  background: transparent;
  outline: none;
  flex: 1;
  font-family: inherit;
  font-size: 14px;
  padding: 6px 10px;
}
.search-form button {
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: 999px;
  width: 34px;
  height: 34px;
  cursor: pointer;
}

/* ===== Hero / Banners ===== */
.hero-slider {
  border-radius: var(--radius);
  overflow: hidden;
  margin: 24px 0;
  box-shadow: var(--shadow);
}
.hero-slider img { width: 100%; height: auto; object-fit: cover; max-height: 420px; }

/* ===== Section headers ===== */
.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 40px 0 20px;
}
.section-title h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--color-primary-dark);
  position: relative;
  padding-right: 14px;
}
.section-title h2::before {
  content: '';
  position: absolute;
  right: 0; top: 4px; bottom: 4px;
  width: 4px;
  background: var(--color-accent);
  border-radius: 4px;
}
.section-title a { color: var(--color-primary); font-size: 14px; font-weight: 500; }

/* ===== Categories ===== */
.categories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 16px;
}
.category-card {
  background: var(--color-surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform .2s, box-shadow .2s;
  text-align: center;
}
.category-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-hover); }
.category-card .cat-img { height: 110px; background: var(--color-bg); display:flex; align-items:center; justify-content:center; overflow:hidden; }
.category-card .cat-img img { width: 100%; height: 100%; object-fit: cover; }
.category-card .cat-name { padding: 12px 8px; font-weight: 600; font-size: 15px; }

/* ===== Products grid ===== */
.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 20px;
}

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

.product-image {
  aspect-ratio: 1 / 1;
  background: var(--color-bg);
  overflow: hidden;
  position: relative;
}
.product-image img { width: 100%; height: 100%; object-fit: cover; transition: transform .35s; }
.product-card:hover .product-image img { transform: scale(1.06); }

.badge-out {
  position: absolute;
  top: 12px; left: 12px;
  background: rgba(43,36,31,0.85);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 999px;
  backdrop-filter: blur(2px);
}
.badge-featured {
  position: absolute;
  top: 12px; right: 12px;
  background: var(--color-accent);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 999px;
}

.product-info { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.product-title { font-size: 15px; font-weight: 600; min-height: 44px; }
.product-price { display: flex; align-items: center; gap: 8px; }
.price-now { font-size: 18px; font-weight: 800; color: var(--color-primary-dark); }
.price-old { font-size: 13px; color: var(--color-text-light); text-decoration: line-through; }

.colors-row { display: flex; gap: 6px; margin-top: 2px; }
.color-dot { width: 18px; height: 18px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--color-border); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  border: none;
  transition: background .2s, opacity .2s, transform .1s;
  font-family: inherit;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-dark); }
.btn-whatsapp { background: #25D366; color: #fff; width: 100%; }
.btn-whatsapp:hover { background: #1ebe57; }
.btn-outline { background: transparent; border: 1.5px solid var(--color-primary); color: var(--color-primary); }
.btn-disabled { background: #d8d2c8; color: #8a8378; cursor: not-allowed; }
.btn-danger { background: var(--color-danger); color: #fff; }
.btn-sm { padding: 6px 14px; font-size: 13px; }

/* ===== Product detail page ===== */
.product-detail {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 40px;
  margin: 32px 0;
}
@media (max-width: 800px) { .product-detail { grid-template-columns: 1fr; } }

.gallery-main {
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 1/1;
  background: var(--color-surface);
  box-shadow: var(--shadow);
  margin-bottom: 12px;
}
.gallery-main img { width: 100%; height: 100%; object-fit: cover; }
.gallery-thumbs { display: flex; gap: 10px; overflow-x: auto; }
.gallery-thumbs img {
  width: 72px; height: 72px; object-fit: cover; border-radius: 10px;
  cursor: pointer; border: 2px solid transparent; opacity: .7;
}
.gallery-thumbs img.active { border-color: var(--color-primary); opacity: 1; }

.product-detail h1 { font-size: 28px; margin: 0 0 8px; color: var(--color-primary-dark); }
.detail-price { font-size: 30px; font-weight: 900; color: var(--color-primary-dark); margin: 12px 0; }
.detail-desc { color: var(--color-text-light); margin: 16px 0; white-space: pre-line; }

.color-options { display: flex; gap: 10px; margin: 10px 0 20px; flex-wrap: wrap; }
.color-option {
  display: flex; align-items: center; gap: 8px;
  border: 1.5px solid var(--color-border);
  border-radius: 999px; padding: 6px 14px; cursor: pointer;
  font-size: 14px; transition: border-color .2s;
}
.color-option.selected { border-color: var(--color-primary); background: #fbf3e8; }
.color-swatch { width: 16px; height: 16px; border-radius: 50%; box-shadow: 0 0 0 1px rgba(0,0,0,.1); }

/* ===== Footer ===== */
.site-footer {
  background: var(--color-primary-dark);
  color: #f4ede1;
  margin-top: 60px;
  padding: 40px 0 20px;
}
.site-footer .container { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 24px; }
.footer-copy { text-align: center; opacity: .7; font-size: 13px; padding-top: 20px; margin-top: 20px; border-top: 1px solid rgba(255,255,255,.1); width:100%; }

.whatsapp-float {
  position: fixed; bottom: 24px; left: 24px; z-index: 60;
  background: #25D366; color: #fff; width: 56px; height: 56px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow-hover);
}

.empty-state { text-align: center; padding: 60px 20px; color: var(--color-text-light); }

/* ===== Admin ===== */
.admin-body { background: #f3f1ec; }
.admin-shell { display: flex; min-height: 100vh; }
.admin-sidebar {
  width: 240px; background: var(--color-primary-dark); color: #fff;
  padding: 24px 16px; flex-shrink: 0;
}
.admin-sidebar .logo { color: #fff; margin-bottom: 30px; display:block; }
.admin-sidebar a {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; border-radius: 10px; margin-bottom: 4px;
  color: #e9dfcf; font-weight: 500; font-size: 14.5px;
}
.admin-sidebar a:hover, .admin-sidebar a.active { background: rgba(255,255,255,.12); color: #fff; }
.admin-main { flex: 1; padding: 28px 32px; }

.admin-topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px,1fr)); gap: 16px; margin-bottom: 30px; }
.stat-card { background: var(--color-surface); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.stat-card .num { font-size: 28px; font-weight: 900; color: var(--color-primary-dark); }
.stat-card .label { color: var(--color-text-light); font-size: 13.5px; }

.admin-table { width: 100%; border-collapse: collapse; background: var(--color-surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.admin-table th, .admin-table td { padding: 12px 14px; text-align: right; border-bottom: 1px solid var(--color-border); font-size: 14px; }
.admin-table th { background: var(--color-bg); font-weight: 700; color: var(--color-text-light); }
.admin-table img.thumb { width: 46px; height: 46px; object-fit: cover; border-radius: 8px; }

.status-pill { padding: 4px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 700; }
.status-available { background: #e5f6ec; color: var(--color-success); }
.status-out { background: #fbe9e7; color: var(--color-danger); }

.form-card { background: var(--color-surface); border-radius: var(--radius); padding: 26px; box-shadow: var(--shadow); max-width: 720px; }
.form-group { margin-bottom: 18px; }
.form-group label { display: block; margin-bottom: 6px; font-weight: 600; font-size: 14px; }
.form-group input[type=text], .form-group input[type=number], .form-group input[type=password],
.form-group input[type=email], .form-group textarea, .form-group select {
  width: 100%; padding: 10px 14px; border-radius: 10px; border: 1.5px solid var(--color-border);
  font-family: inherit; font-size: 14.5px; background: #fff;
}
.form-group textarea { min-height: 110px; resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; }

.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #f4ede1, #e8dcc7);
}
.login-card { background: #fff; border-radius: 18px; padding: 40px; width: 360px; box-shadow: var(--shadow-hover); text-align: center; }
.login-card .logo { justify-content: center; margin-bottom: 6px; font-size: 26px; }
.alert-error { background: #fbe9e7; color: var(--color-danger); padding: 10px 14px; border-radius: 10px; font-size: 13.5px; margin-bottom: 16px; }

@media (max-width: 780px) {
  .nav-links { display: none; }
  .admin-sidebar { position: fixed; right: -260px; transition: right .2s; height: 100%; z-index: 80; }
  .admin-sidebar.open { right: 0; }
  .admin-main { padding: 20px 16px; }
  .form-row { grid-template-columns: 1fr; }
}
