/* ==========================================================================
   Base — design tokens, reset, typography and primitives shared by the
   storefront and the admin dashboard. Logical properties throughout so
   Arabic (RTL) works without overrides.
   ========================================================================== */

:root {
  color-scheme: dark;

  --bg: #0a0a0b;
  --bg-raised: #111113;
  --bg-card: #151517;
  --bg-card-hover: #1b1b1e;
  --bg-input: #19191c;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);

  --text: #f3efe8;
  --text-2: #bcb6ac;
  --text-3: #8d887f;

  --gold: #c8a96a;
  --gold-bright: #e4cf9f;
  --gold-deep: #9d7f45;
  --gold-tint: rgba(200, 169, 106, 0.12);
  --gold-line: rgba(200, 169, 106, 0.35);

  --success: #5cc991;
  --warning: #e9a84c;
  --danger: #ee5d5d;
  --info: #6aa8ea;
  --whatsapp: #25d366;

  --font-sans: 'Plus Jakarta Sans', 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: 'Playfair Display', 'Cormorant Garamond', 'Times New Roman', serif;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 28px;
  --radius-pill: 999px;

  --shadow-md: 0 12px 30px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 30px 80px rgba(0, 0, 0, 0.55);
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);

  --container: 1320px;
  --gutter: clamp(1.25rem, 4vw, 2.5rem);
  --header-h: 76px;
}

html[lang='ar'] {
  --font-sans: 'Cairo', 'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, sans-serif;
  --font-display: 'El Messiri', 'Cairo', serif;
}

/* --- Reset --------------------------------------------------------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 16px);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img,
svg,
video,
iframe {
  display: block;
  max-width: 100%;
}

img {
  height: auto;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

h1,
h2,
h3,
h4,
p,
figure,
blockquote,
dl,
dd {
  margin: 0;
}

ul[class],
ol[class] {
  margin: 0;
  padding: 0;
  list-style: none;
}

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}

::selection {
  background: var(--gold);
  color: #16130d;
}

[hidden] {
  display: none !important;
}

body.no-scroll {
  overflow: hidden;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.flip-rtl:dir(rtl) {
  transform: scaleX(-1);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* --- Typography --------------------------------------------------------- */

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold);
}

.eyebrow::before {
  content: '';
  width: 28px;
  height: 1px;
  background: currentColor;
}

html[lang='ar'] .eyebrow {
  letter-spacing: 0;
  font-size: 0.875rem;
}

.display {
  font-family: var(--font-display);
  font-weight: 500;
  line-height: 1.04;
  letter-spacing: -0.01em;
}

html[lang='ar'] .display {
  line-height: 1.35;
  letter-spacing: 0;
}

.muted {
  color: var(--text-2);
}

.text-gold {
  color: var(--gold-bright);
}

/* --- Buttons ------------------------------------------------------------ */

.btn {
  --btn-bg: transparent;
  --btn-fg: var(--text);
  --btn-border: var(--line-strong);
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  min-height: 48px;
  padding: 0 1.4rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--btn-border);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-weight: 600;
  font-size: 0.9375rem;
  white-space: nowrap;
  transition:
    background 0.25s var(--ease),
    color 0.25s var(--ease),
    border-color 0.25s var(--ease),
    transform 0.25s var(--ease),
    box-shadow 0.25s var(--ease);
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.btn i {
  font-size: 1.15em;
  line-height: 1;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg);
}
::-webkit-scrollbar-thumb {
  background: rgba(200, 169, 106, 0.35);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--gold);
}

.btn--primary {
  --btn-bg: linear-gradient(135deg, #e4cf9f 0%, #c8a96a 50%, #b39352 100%);
  --btn-fg: #0e0d0b;
  --btn-border: rgba(228, 207, 159, 0.5);
  font-weight: 700;
  letter-spacing: 0.02em;
  box-shadow: 0 8px 24px -6px rgba(200, 169, 106, 0.45);
}

.btn--primary:hover:not(:disabled) {
  --btn-bg: linear-gradient(135deg, #f0dfb6 0%, #d4af37 50%, #c8a96a 100%);
  --btn-border: var(--gold-bright);
  transform: translateY(-2px);
  box-shadow: 0 12px 30px -4px rgba(200, 169, 106, 0.65);
}

.btn--ghost:hover:not(:disabled) {
  --btn-border: var(--gold);
  --btn-fg: var(--gold-bright);
}

.btn--light {
  --btn-bg: var(--text);
  --btn-fg: #111;
  --btn-border: var(--text);
}

.btn--whatsapp {
  --btn-border: rgba(37, 211, 102, 0.45);
  --btn-fg: #8be6b1;
}

.btn--whatsapp:hover:not(:disabled) {
  --btn-bg: var(--whatsapp);
  --btn-fg: #052011;
  --btn-border: var(--whatsapp);
}

.btn--danger {
  --btn-border: rgba(238, 93, 93, 0.4);
  --btn-fg: #ff9a9a;
}

.btn--danger:hover:not(:disabled) {
  --btn-bg: var(--danger);
  --btn-fg: #fff;
  --btn-border: var(--danger);
}

.btn--sm {
  min-height: 38px;
  padding: 0 1rem;
  font-size: 0.8125rem;
}

.btn--block {
  width: 100%;
}

.btn.is-loading {
  color: transparent;
  pointer-events: none;
}

.btn.is-loading::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--btn-fg);
  border-inline-end-color: transparent;
  animation: spin 0.7s linear infinite;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--text);
  font-size: 1.15rem;
  transition:
    border-color 0.2s var(--ease),
    color 0.2s var(--ease),
    background 0.2s var(--ease);
}

.icon-btn:hover {
  border-color: var(--gold);
  color: var(--gold-bright);
}

/* --- Forms ---------------------------------------------------------------- */

.field {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.45rem;
  min-width: 0;
}

.field__label {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-2);
}

html[lang='ar'] .field__label {
  letter-spacing: 0;
  font-size: 0.8125rem;
}

.field__hint {
  font-size: 0.8125rem;
  color: var(--text-3);
}

.field__error {
  font-size: 0.8125rem;
  color: var(--danger);
}

.control {
  width: 100%;
  min-height: 50px;
  padding: 0.7rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--line-strong);
  background: var(--bg-input);
  color: var(--text);
  font-size: 0.9375rem;
  transition:
    border-color 0.2s var(--ease),
    box-shadow 0.2s var(--ease);
}

.control::placeholder {
  color: var(--text-3);
}

.control:hover {
  border-color: rgba(255, 255, 255, 0.26);
}

.control:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-tint);
}

.control[aria-invalid='true'] {
  border-color: var(--danger);
}

textarea.control {
  min-height: 110px;
  resize: vertical;
}

select.control {
  appearance: none;
  padding-inline-end: 2.6rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' stroke='%23bcb6ac' stroke-width='1.6'%3E%3Cpath d='m1 1.5 5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
}

select.control:dir(rtl) {
  background-position: left 1rem center;
}

select.control option {
  background: var(--bg-raised);
}

input[type='datetime-local'].control,
input[type='date'].control {
  color-scheme: dark;
}

.check {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
}

.check input {
  width: 18px;
  height: 18px;
  accent-color: var(--gold);
  cursor: pointer;
}

/* --- Badges & chips ---------------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.7rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line-strong);
  background: rgba(10, 10, 11, 0.72);
  color: var(--text);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  backdrop-filter: blur(8px);
}

html[lang='ar'] .badge {
  letter-spacing: 0;
  font-size: 0.75rem;
}

.badge--gold {
  background: var(--gold);
  border-color: var(--gold);
  color: #16130d;
}

.badge--dot::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge--success {
  color: var(--success);
  border-color: rgba(92, 201, 145, 0.35);
}

.badge--warning {
  color: var(--warning);
  border-color: rgba(233, 168, 76, 0.35);
}

.badge--danger {
  color: var(--danger);
  border-color: rgba(238, 93, 93, 0.35);
}

.badge--info {
  color: var(--info);
  border-color: rgba(106, 168, 234, 0.35);
}

.badge--muted {
  color: var(--text-2);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 40px;
  padding: 0 1.05rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--text-2);
  font-size: 0.875rem;
  font-weight: 600;
  white-space: nowrap;
  transition:
    background 0.2s var(--ease),
    color 0.2s var(--ease),
    border-color 0.2s var(--ease);
}

.chip:hover {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.3);
}

.chip.is-active {
  background: var(--text);
  border-color: var(--text);
  color: #111;
}

.chip__count {
  font-size: 0.75rem;
  opacity: 0.6;
}

/* --- Dialog ------------------------------------------------------------------- */

dialog.modal {
  width: min(560px, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  background: var(--bg-raised);
  color: var(--text);
  box-shadow: var(--shadow-lg);
}

dialog.modal::backdrop {
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
}

dialog.modal[open] {
  animation: rise 0.35s var(--ease);
}

/* --- Toasts ------------------------------------------------------------------- */

.toast-stack {
  position: fixed;
  inset-block-end: 1.5rem;
  inset-inline: 0;
  z-index: 1000;
  display: grid;
  justify-items: center;
  gap: 0.5rem;
  padding-inline: 1rem;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  max-width: 440px;
  padding: 0.8rem 1.15rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--line-strong);
  background: rgba(24, 24, 27, 0.96);
  box-shadow: var(--shadow-md);
  font-size: 0.9rem;
  pointer-events: auto;
  animation: rise 0.3s var(--ease);
}

.toast i {
  font-size: 1.2rem;
}

.toast--success i {
  color: var(--success);
}

.toast--error i {
  color: var(--danger);
}

.toast.is-leaving {
  opacity: 0;
  transform: translateY(8px);
  transition:
    opacity 0.25s,
    transform 0.25s;
}

/* --- Skeletons & motion ---------------------------------------------------------- */

.skeleton {
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.04) 25%, rgba(255, 255, 255, 0.08) 50%, rgba(255, 255, 255, 0.04) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
  border-radius: var(--radius-md);
}

@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
}
