/* ============================================================
   E-commerce store — public styles (RTL Arabic)
   Rule (project requirement): [hidden] must always hide
   ============================================================ */
[hidden] { display: none !important; }

* { box-sizing: border-box; }

:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --text: #1a1a1a;
  --muted: #6b7280;
  --primary: #e11d48;
  --primary-dark: #be123c;
  --secondary: #0f172a;
  --accent: #f59e0b;
  --ok: #16a34a;
  --bad: #dc2626;
  --border: #e5e7eb;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-lg: 0 10px 30px rgba(0,0,0,.08);
  --radius: 12px;
  --radius-sm: 8px;
}

html, body { margin: 0; padding: 0; }
body {
  font-family: 'Cairo', 'Tajawal', system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; width: 100%; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.center { text-align: center; }
.right { text-align: left; } /* RTL flip */
.mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-block;
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform .08s ease, box-shadow .15s ease, background .15s ease, color .15s ease;
  text-align: center;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--secondary); color: #fff; }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-ghost:hover { background: #f3f4f6; }
.btn-danger { background: var(--bad); color: #fff; }
.btn-lg { padding: 14px 26px; font-size: 1.05rem; }
.btn-sm { padding: 6px 12px; font-size: .85rem; }
.btn-block { display: block; width: 100%; }

/* ---------- Header ---------- */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
  box-shadow: var(--shadow);
}
.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px;
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 1.25rem; font-weight: 800; }
.brand-mark { font-size: 1.5rem; }
.main-nav { display: flex; gap: 6px; align-items: center; }
.main-nav a {
  padding: 8px 14px; border-radius: var(--radius-sm); color: var(--text); font-weight: 500;
}
.main-nav a:hover { background: #f3f4f6; }
.main-nav a.active { background: var(--primary); color: #fff; }
.main-nav .admin-link { background: var(--secondary); color: #fff; }
.main-nav .admin-link:hover { background: #000; }
.badge {
  display: inline-block; background: var(--accent); color: #fff;
  font-size: 0.75rem; padding: 1px 8px; border-radius: 999px; margin-inline-start: 4px;
  font-weight: 700;
}

.flash {
  background: #ecfdf5; color: #065f46; border-bottom: 1px solid #a7f3d0;
  padding: 10px 0; font-weight: 600; text-align: center;
}

.main-content { flex: 1; padding: 28px 20px 60px; }

/* ---------- Hero ---------- */
.hero {
  background:
    radial-gradient(1200px 400px at 50% -100px, rgba(225,29,72,.15), transparent),
    linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  color: #fff;
  border-radius: var(--radius);
  margin-bottom: 36px;
  padding: 64px 24px;
  text-align: center;
}
.hero h1 { margin: 0 0 10px; font-size: clamp(1.6rem, 3.2vw, 2.6rem); font-weight: 800; }
.hero p { margin: 0 0 22px; font-size: 1.1rem; color: #cbd5e1; }
.hero .btn { color: #fff; }
.hero-inner { max-width: 700px; margin: 0 auto; }

/* ---------- Sections ---------- */
.section { margin: 32px 0; }
.section-title { font-size: 1.4rem; font-weight: 800; margin: 0 0 18px; }
.page-title { font-size: 1.7rem; font-weight: 800; margin: 0 0 18px; }

/* ---------- Filters ---------- */
.filters {
  display: flex; gap: 10px; margin: 0 0 24px; flex-wrap: wrap;
}
.filters .input { flex: 1; min-width: 180px; }

.input {
  display: block; width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font: inherit;
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.input:focus { outline: 0; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(225,29,72,.12); }
.input.small { padding: 6px 10px; width: auto; }
.input.lg { padding: 14px 16px; font-size: 1rem; }

textarea.input { resize: vertical; }

/* ---------- Product grid ---------- */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform .15s, box-shadow .15s;
  display: flex; flex-direction: column;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.card-img {
  position: relative; aspect-ratio: 1/1; background: #f3f4f6; overflow: hidden;
}
.card-img img { width: 100%; height: 100%; object-fit: cover; }
.no-img { display: flex; align-items: center; justify-content: center; color: var(--muted); height: 100%; }
.no-img.large { font-size: 1.1rem; }
.ribbon {
  position: absolute; top: 10px; inset-inline-end: 10px;
  background: var(--accent); color: #fff;
  font-size: .7rem; font-weight: 700; padding: 3px 10px; border-radius: 999px;
}
.ribbon.small { position: static; font-size: .65rem; padding: 1px 6px; }
.card-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.card-title { margin: 0; font-size: 1rem; font-weight: 700; line-height: 1.4; }
.card-title a:hover { color: var(--primary); }
.card-price { font-size: 1.15rem; font-weight: 800; color: var(--primary); }
.card-form { margin-top: auto; }
.card-form .btn { width: 100%; }

/* ---------- Product detail ---------- */
.product-detail {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 36px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}
.detail-img {
  background: #f3f4f6; border-radius: var(--radius-sm); overflow: hidden;
  aspect-ratio: 1/1;
}
.detail-img img { width: 100%; height: 100%; object-fit: contain; }
.detail-body h1 { font-size: 1.8rem; font-weight: 800; margin: 8px 0 12px; }
.meta { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.chip {
  background: #f3f4f6; color: #374151; padding: 4px 12px; border-radius: 999px; font-size: .85rem;
}
.chip.ok { background: #dcfce7; color: #166534; }
.chip.bad { background: #fee2e2; color: #991b1b; }
.chip.ghost { background: transparent; border: 1px solid var(--border); }
.price-big { font-size: 2.2rem; font-weight: 900; color: var(--primary); margin: 8px 0 18px; }
.description { color: #374151; white-space: pre-wrap; }
.back-link { display: inline-block; color: var(--muted); margin-bottom: 10px; }
.back-link:hover { color: var(--primary); }
.add-form { display: flex; gap: 10px; align-items: end; margin-top: 24px; flex-wrap: wrap; }
.add-form label { display: flex; flex-direction: column; gap: 4px; }
.add-form .qty { width: 100px; }

@media (max-width: 720px) {
  .product-detail { grid-template-columns: 1fr; padding: 16px; }
  .main-nav { gap: 2px; }
  .main-nav a { padding: 6px 10px; font-size: .9rem; }
  .hero { padding: 40px 20px; }
}

/* ---------- Cart ---------- */
.cart-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 24px; }
.cart-item {
  display: grid;
  grid-template-columns: 80px 1fr auto auto;
  gap: 14px; align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 10px;
}
.ci-img { width: 80px; height: 80px; background: #f3f4f6; border-radius: var(--radius-sm); overflow: hidden; }
.ci-img img { width: 100%; height: 100%; object-fit: cover; }
.ci-name { font-weight: 700; }
.ci-price { color: var(--primary); font-weight: 800; }
.ci-qty { display: flex; gap: 6px; align-items: center; }
.cart-summary {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; height: max-content;
  position: sticky; top: 90px;
}
.cart-summary h3 { margin: 0 0 14px; }
.cart-summary .row {
  display: flex; justify-content: space-between; padding: 6px 0;
}
.cart-summary hr { border: 0; border-top: 1px solid var(--border); margin: 8px 0; }
.cart-summary .total { font-size: 1.2rem; padding-top: 10px; border-top: 1px dashed var(--border); }

.empty { padding: 40px; text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); }

@media (max-width: 720px) {
  .cart-grid { grid-template-columns: 1fr; }
  .cart-item { grid-template-columns: 60px 1fr; }
  .ci-img { width: 60px; height: 60px; }
  .ci-qty, .cart-item form[action*="remove"] { grid-column: 2; }
}

/* ---------- Checkout ---------- */
.checkout-form { display: flex; flex-direction: column; gap: 12px; }
.checkout-form label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; }

/* ---------- Success card ---------- */
.success-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 40px; max-width: 500px; margin: 0 auto; }
.success-icon { font-size: 3rem; margin-bottom: 10px; }

/* ---------- Footer ---------- */
.site-footer { background: #0f172a; color: #cbd5e1; margin-top: 60px; padding: 40px 0 20px; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 30px; }
.site-footer h4 { color: #fff; margin: 0 0 12px; }
.site-footer a { display: block; padding: 4px 0; color: #cbd5e1; }
.site-footer a:hover { color: #fff; }
.copyright { text-align: center; margin-top: 30px; padding-top: 20px; border-top: 1px solid #1e293b; color: #94a3b8; }

@media (max-width: 720px) { .footer-grid { grid-template-columns: 1fr; } }

/* ---------- Alerts ---------- */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; border: 1px solid transparent; }
.alert.error { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.alert.ok { background: #f0fdf4; color: #166534; border-color: #bbf7d0; }
.alert.info { background: #eff6ff; color: #1e40af; border-color: #bfdbfe; }
.alert.warn { background: #fffbeb; color: #92400e; border-color: #fde68a; }

h1 code, h2 code, p code, li code { background: #f3f4f6; padding: 1px 6px; border-radius: 4px; font-size: 0.9em; }
