/* ============================================================
   Qita' (قطع) — design system
   Tokens · layout · components · RTL-aware (logical properties)
   ============================================================ */

@layer reset, tokens, base, components, utilities;

@layer reset {
  *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
  img, svg { display: block; max-width: 100%; }
  button, input, select, textarea { font: inherit; color: inherit; }
}

@layer tokens {
  :root {
    --font-sans: "IBM Plex Sans Arabic", "Tajawal", ui-sans-serif, system-ui, sans-serif;
    --color-brand-50:  #f0f7f4; --color-brand-100: #dcefe6; --color-brand-200: #b9dfce;
    --color-brand-300: #8cc6b0; --color-brand-400: #5aa88d; --color-brand-500: #3a8c70;
    --color-brand-600: #2b7059; --color-brand-700: #245a49; --color-brand-800: #1f483c;
    --color-brand-900: #1b3c33;
    --color-sand-50: #fbf8f1; --color-sand-100: #f5eedd; --color-sand-200: #eadbba;
    --color-sand-300: #dcc28d;
    --color-ink: #1f2937; --color-muted: #6b7280; --color-border: #e5e7eb;
    --shadow-1: 0 1px 2px rgba(0,0,0,.06);
    --shadow-2: 0 4px 16px rgba(0,0,0,.08);
    --shadow-3: 0 12px 40px rgba(0,0,0,.14);
    --radius-sm: .5rem; --radius-md: .85rem; --radius-lg: 1.25rem; --radius-full: 999px;
    --space-1: .25rem; --space-2: .5rem; --space-3: .75rem; --space-4: 1rem;
    --space-6: 1.5rem; --space-8: 2rem; --space-12: 3rem; --space-16: 4rem;
  }
}

@layer base {
  html { -webkit-text-size-adjust: 100%; }
  body {
    font-family: var(--font-sans);
    background: #f9fafb;
    color: var(--color-ink);
    line-height: 1.6;
    font-size: 16px;
  }
  h1, h2, h3, h4 { line-height: 1.3; text-wrap: balance; }
  a { color: inherit; text-decoration: none; }
  ::selection { background: var(--color-brand-200); }
  :focus-visible { outline: 2px solid var(--color-brand-500); outline-offset: 2px; border-radius: 4px; }
}

@layer components {
  /* ---------- header ---------- */
  .site-header {
    position: sticky; top: 0; z-index: 40;
    background: rgba(255,255,255,.92);
    backdrop-filter: blur(12px);
    border-block-end: 1px solid var(--color-border);
  }
  .logo-mark {
    width: 40px; height: 40px; border-radius: 12px;
    background: linear-gradient(135deg, var(--color-brand-500), var(--color-brand-700));
    color: #fff; display: inline-flex; align-items: center; justify-content: center;
    box-shadow: var(--shadow-2);
  }
  .logo-mark-sm { width: 30px; height: 30px; font-size: .85rem; border-radius: 9px; }
  .nav-link {
    padding: .5rem .8rem; border-radius: var(--radius-sm); font-weight: 500; font-size: .925rem;
    color: #374151; transition: background .15s, color .15s; position: relative;
  }
  .nav-link:hover { background: var(--color-brand-50); color: var(--color-brand-700); }
  .dot-badge {
    position: absolute; inset-inline-start: 1.55rem; top: .3rem;
    width: 8px; height: 8px; border-radius: 50%; background: #ef4444;
  }
  .mobile-menu { background: #fff; border-block-end: 1px solid var(--color-border); }

  /* ---------- buttons ---------- */
  .btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
    padding: .65rem 1.3rem; border-radius: var(--radius-md);
    font-weight: 700; font-size: .95rem; cursor: pointer; border: 1px solid transparent;
    transition: transform .1s, box-shadow .15s, background .15s, border-color .15s;
    white-space: nowrap;
  }
  .btn:active { transform: translateY(1px); }
  .btn:disabled { opacity: .55; cursor: not-allowed; }
  .btn-primary {
    background: linear-gradient(135deg, var(--color-brand-500), var(--color-brand-700));
    color: #fff; box-shadow: var(--shadow-2);
  }
  .btn-primary:hover:not(:disabled) { box-shadow: var(--shadow-3); filter: brightness(1.05); }
  .btn-outline { background: #fff; border-color: #d1d5db; color: #374151; }
  .btn-outline:hover:not(:disabled) { border-color: var(--color-brand-500); color: var(--color-brand-700); }
  .btn-ghost { background: transparent; color: #4b5563; }
  .btn-ghost:hover { background: rgba(0,0,0,.05); }
  .btn-lg { padding: .9rem 2rem; font-size: 1.05rem; border-radius: var(--radius-md); }
  .btn-sm { padding: .4rem .9rem; font-size: .85rem; border-radius: var(--radius-sm); }

  /* ---------- cards ---------- */
  .card {
    background: #fff; border: 1px solid var(--color-border);
    border-radius: var(--radius-md); box-shadow: var(--shadow-1);
  }
  .hover-card { transition: box-shadow .2s, transform .2s; }
  .hover-card:hover { box-shadow: var(--shadow-2); transform: translateY(-2px); }
  .success-card { border: 2px solid var(--color-brand-300); background: linear-gradient(180deg, #fff, var(--color-brand-50)); }

  /* ---------- badges ---------- */
  .badge {
    display: inline-flex; align-items: center; gap: .3rem;
    font-size: .72rem; font-weight: 700; padding: .22rem .6rem;
    border-radius: var(--radius-full); white-space: nowrap;
  }
  .badge-oem { background: #e0f2fe; color: #0369a1; }
  .badge-used { background: #fef3c7; color: #b45309; }
  .badge-am { background: #f3e8ff; color: #7e22ce; }
  .badge-green { background: #dcfce7; color: #15803d; }
  .badge-blue { background: #e0f2fe; color: #0369a1; }
  .badge-red { background: #fee2e2; color: #b91c1c; }
  .badge-amber { background: #fef3c7; color: #b45309; }
  .badge-gray { background: #f3f4f6; color: #4b5563; }

  /* ---------- forms ---------- */
  .form-label { display: block; font-size: .85rem; font-weight: 600; color: #374151; margin-block-end: .4rem; }
  .form-input {
    width: 100%; padding: .7rem .9rem; border: 1px solid #d1d5db; border-radius: var(--radius-sm);
    background: #fff; font-size: .95rem; transition: border-color .15s, box-shadow .15s;
  }
  .form-input:focus { outline: none; border-color: var(--color-brand-500); box-shadow: 0 0 0 3px rgba(58,140,112,.15); }
  textarea.form-input { resize: vertical; }

  /* ---------- chips ---------- */
  .chip {
    display: inline-flex; align-items: center; gap: .35rem;
    padding: .42rem .95rem; border-radius: var(--radius-full);
    border: 1.5px solid #d1d5db; background: #fff; color: #4b5563;
    font-size: .85rem; font-weight: 600; cursor: pointer; transition: all .15s;
  }
  .chip:hover { border-color: var(--color-brand-400); }
  .chip-on { background: var(--color-brand-600); border-color: var(--color-brand-600); color: #fff; }
  .chip-group { display: flex; flex-wrap: wrap; gap: .5rem; }

  /* ---------- wizard ---------- */
  .photo-drop {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .5rem;
    padding: 1.5rem; border: 2px dashed #cbd5e1; border-radius: var(--radius-md);
    color: var(--color-muted); cursor: pointer; transition: border-color .15s, background .15s;
    margin-block-start: .4rem;
  }
  .photo-drop:hover { border-color: var(--color-brand-500); background: var(--color-brand-50); }

  /* ---------- hero ---------- */
  .hero { position: relative; background: linear-gradient(135deg, var(--color-brand-900), var(--color-brand-700) 60%, var(--color-brand-500)); overflow: hidden; }
  .hero-grid {
    position: absolute; inset: 0; opacity: .12;
    background-image: linear-gradient(rgba(255,255,255,.5) 1px, transparent 1px),
                      linear-gradient(90deg, rgba(255,255,255,.5) 1px, transparent 1px);
    background-size: 42px 42px;
    mask-image: radial-gradient(ellipse at center, #000 40%, transparent 75%);
  }
  .hero-glow { position: absolute; width: 60vw; height: 60vw; border-radius: 50%; background: radial-gradient(circle, rgba(255,255,255,.14), transparent 65%); top: -20vw; inset-inline-end: -15vw; }

  /* ---------- sections ---------- */
  .section-title { text-align: center; font-size: clamp(1.6rem, 3vw, 2.2rem); font-weight: 900; color: var(--color-brand-800); }
  .section-sub { font-size: 1.1rem; font-weight: 800; color: var(--color-brand-800); }
  .step-circle {
    width: 56px; height: 56px; margin-inline: auto; border-radius: 50%;
    background: linear-gradient(135deg, var(--color-brand-400), var(--color-brand-600));
    color: #fff; font-size: 1.4rem; font-weight: 900;
    display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow-2);
  }
  .step-dot {
    width: 26px; height: 26px; border-radius: 50%; background: var(--color-brand-100);
    color: var(--color-brand-700); font-weight: 800; font-size: .8rem;
    display: inline-flex; align-items: center; justify-content: center;
  }

  /* ---------- tabs ---------- */
  .tabs { display: flex; gap: .25rem; border-block-end: 2px solid var(--color-border); flex-wrap: wrap; }
  .tab {
    padding: .6rem 1.1rem; font-weight: 600; font-size: .92rem; color: #6b7280;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0; transition: all .15s;
    border-block-end: 2px solid transparent; margin-block-end: -2px;
  }
  .tab:hover { color: var(--color-brand-700); }
  .tab-on { color: var(--color-brand-700); border-block-end-color: var(--color-brand-600); background: var(--color-brand-50); }

  /* ---------- modal ---------- */
  .modal-overlay {
    position: fixed; inset: 0; z-index: 100;
    background: rgba(17,24,39,.55); backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center; padding: 1rem;
    opacity: 0; transition: opacity .2s; overflow-y: auto;
  }
  .modal-overlay.show { opacity: 1; }
  .modal-card {
    position: relative; background: #fff; border-radius: var(--radius-lg); padding: 1.75rem;
    max-width: 30rem; width: 100%; box-shadow: var(--shadow-3);
    transform: translateY(12px) scale(.98); transition: transform .2s;
  }
  .modal-overlay.show .modal-card { transform: none; }
  .modal-close {
    position: absolute; top: .9rem; inset-inline-end: .9rem;
    width: 34px; height: 34px; border-radius: 50%; border: none; cursor: pointer;
    background: #f3f4f6; color: #4b5563; display: inline-flex; align-items: center; justify-content: center;
    transition: background .15s;
  }
  .modal-close:hover { background: #e5e7eb; }
  .pay-option {
    display: flex; align-items: center; gap: .5rem; justify-content: center;
    padding: .7rem; border: 1.5px solid #d1d5db; border-radius: var(--radius-sm);
    background: #fff; font-size: .85rem; font-weight: 600; color: #4b5563; cursor: pointer; transition: all .15s;
  }
  .pay-on { border-color: var(--color-brand-600); background: var(--color-brand-50); color: var(--color-brand-800); }

  /* ---------- stars ---------- */
  .star-row { display: flex; gap: .2rem; }
  .star {
    background: none; border: none; font-size: 1.6rem; color: #e5e7eb; cursor: pointer; padding: .1rem;
    transition: color .12s, transform .12s;
  }
  .star:hover { transform: scale(1.15); }
  .star.on { color: #f59e0b; }

  /* ---------- toast ---------- */
  #toast-root {
    position: fixed; bottom: 1.25rem; inset-inline-end: 1.25rem; z-index: 200;
    display: flex; flex-direction: column; gap: .5rem;
  }
  .toast {
    padding: .8rem 1.2rem; border-radius: var(--radius-md); color: #fff; font-weight: 600; font-size: .9rem;
    box-shadow: var(--shadow-3); opacity: 0; transform: translateY(10px); transition: all .25s; max-width: 22rem;
  }
  .toast.show { opacity: 1; transform: none; }
  .toast-success { background: var(--color-brand-700); }
  .toast-error { background: #dc2626; }

  /* ---------- footer ---------- */
  .site-footer { border-block-start: 1px solid var(--color-border); background: #fff; margin-block-start: 2rem; }

  /* ---------- icons ---------- */
  .rtl-arrow { transform: scaleX(-1); }
  html[dir="ltr"] .rtl-arrow { transform: none; }
}

@layer utilities {
  .container { width: 100%; margin-inline: auto; }
  .hidden { display: none !important; }
}

/* ---------- responsive ---------- */
@media (min-width: 640px)  { .container { max-width: 640px; } }
@media (min-width: 768px)  { .container { max-width: 768px; } }
@media (min-width: 1024px) { .container { max-width: 1024px; } }
@media (min-width: 1280px) { .container { max-width: 1216px; } }

/* ---------- a11y ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
