/* ============================================================================
   HiBargh — Account & Auth pages  →  ac-
   Styles login.php, account.php, account-orders.php, account-profile.php onto
   the "جریان / current" design system. Loaded AFTER css/hibargh.css (see
   $hbExtraCss in each page + includes/header.php), so this file reuses the
   :root tokens and primitives declared there (glass, gel, btn, wrap, --r-*,
   --fs-*, --spring-*, OKLCH palette) instead of inventing new ones. Pages still
   wrap content in the legacy `.container` (style.css) for gutter/max-width —
   left alone; only `ac-` namespaced rules live here, plus narrow, scoped resets
   of legacy heading/element bleed inside that namespace.
   RTL-first: logical properties throughout, no left/right physicals.
   ========================================================================== */

/* ————— shared: alerts ————— */
.ac-alert {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.9rem 1rem;
  border-radius: var(--r-md);
  font-size: var(--fs-sm);
  line-height: 1.7;
  margin-block-end: 1.1rem;
}
.ac-alert i,
.ac-alert svg {
  flex-shrink: 0;
  inline-size: 19px;
  block-size: 19px;
  margin-block-start: 0.1rem;
}
.ac-alert span { min-inline-size: 0; }
.ac-alert a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }

.ac-alert--err {
  color: oklch(0.42 0.17 25);
  background: oklch(0.6 0.19 25 / 0.1);
  box-shadow: inset 0 0 0 1px oklch(0.6 0.19 25 / 0.18);
}
.ac-alert--ok {
  color: oklch(0.4 0.11 155);
  background: oklch(0.6 0.14 155 / 0.1);
  box-shadow: inset 0 0 0 1px oklch(0.6 0.14 155 / 0.18);
}
.ac-alert--info {
  color: var(--primary-ink);
  background: oklch(0.7 0.14 256 / 0.1);
  box-shadow: inset 0 0 0 1px oklch(0.7 0.14 256 / 0.18);
}

/* ————— shared: quiet link / inline button ————— */
.ac-link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font: inherit;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--primary-ink);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  text-decoration: none;
  transition: opacity 200ms ease;
}
.ac-link:hover { opacity: 0.72; text-decoration: underline; text-underline-offset: 3px; }

/* ————— shared: form field / input ————— */
.ac-field {
  display: grid;
  gap: 0.45rem;
  margin-block-end: 1.1rem;
}
.ac-field label {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--ink);
}
.ac-input {
  inline-size: 100%;
  min-block-size: 48px;
  padding-inline: 1rem;
  padding-block: 0.6rem;
  border-radius: var(--r-md);
  border: 0;
  font: inherit;
  font-size: var(--fs-base);
  color: var(--ink);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
  transition: box-shadow 200ms ease, background 200ms ease;
}
.ac-input::placeholder { color: var(--muted); }
.ac-input:hover { background: var(--surface-2); }
.ac-input:focus-visible {
  outline: 2.5px solid var(--primary);
  outline-offset: 2px;
  background: oklch(1 0 0);
}
.ac-input[readonly] {
  color: var(--muted);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
  cursor: not-allowed;
}
.ac-input[readonly]:hover { background: var(--surface); }

/* ————— OTP code entry (5 digits) ————— */
/* Fallback (no JS): one centered field, sized so all 5 digits fit unclipped. */
.ac-input--code {
  inline-size: 100%;
  max-inline-size: 300px;
  margin-inline: auto;
  padding-inline: 0.75rem;
  text-align: center;
  font-size: var(--fs-lg);
  font-weight: 700;
  letter-spacing: 0.5em;
  text-indent: 0.5em; /* offset the trailing letter-spacing so digits look centered */
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

/* Enhanced (JS): 5 discrete boxes; the real input is a transparent hit-layer on
   top (keeps native keyboard, paste, and one-time-code autofill working). */
.ac-otp { position: relative; inline-size: 100%; }
.ac-otp.is-enhanced .ac-input--code {
  position: absolute;
  inset: 0;
  inline-size: 100%;
  max-inline-size: none;
  min-block-size: 0;
  margin: 0;
  padding: 0;
  z-index: 2;
  color: transparent;
  caret-color: transparent;
  background: transparent;
  box-shadow: none;
  letter-spacing: normal;
  text-indent: 0;
  cursor: pointer;
}
.ac-otp.is-enhanced .ac-input--code::placeholder { color: transparent; }
.ac-otp.is-enhanced .ac-input--code:focus-visible { outline: none; background: transparent; }

/* LTR so boxes fill left→right, matching the numeric code as it reads in the SMS
   (the field itself is dir="ltr"); without this the digits appear reversed in RTL. */
.ac-otpBoxes { display: none; gap: 0.5rem; justify-content: center; direction: ltr; }
.ac-otp.is-enhanced .ac-otpBoxes { display: flex; }
.ac-otpBox {
  inline-size: clamp(46px, 15vw, 56px);
  block-size: clamp(54px, 16vw, 64px);
  display: grid;
  place-items: center;
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
  font-size: var(--fs-xl);
  font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  transition: box-shadow 180ms ease, background 180ms ease, transform 180ms var(--spring-pop);
}
.ac-otpBox.is-filled {
  background: oklch(1 0 0);
  box-shadow: inset 0 0 0 1.5px var(--primary);
  transform: translateY(-1px);
}
/* the next box to fill, highlighted only while the field is focused */
.ac-otp.is-focused .ac-otpBox.is-active {
  box-shadow: inset 0 0 0 2px var(--primary);
  background: oklch(1 0 0);
}
.ac-otp.is-focused .ac-otpBox.is-active::after {
  content: "";
  inline-size: 2px;
  block-size: 1.5rem;
  background: var(--primary);
  border-radius: 1px;
  animation: ac-caret 1s steps(1) infinite;
}
@keyframes ac-caret { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .ac-otpBox { transition: none; }
  .ac-otpBox.is-filled { transform: none; }
  .ac-otp.is-focused .ac-otpBox.is-active::after { animation: none; }
}

.ac-hint {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.6;
}
.ac-opt {
  font-size: 0.76rem;
  font-weight: 400;
  color: var(--muted);
}

.ac-submit { margin-block-start: 0.3rem; }

/* ————— shared: section headers ————— */
.ac-sectHead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-block-end: 1rem;
}
.ac-sectHead h2 {
  margin: 0;
  font-size: var(--fs-md);
  font-weight: 700;
  color: var(--ink);
}
.ac-sectHead--page {
  align-items: flex-start;
  margin-block-end: 1.6rem;
}
.ac-sectHead--page h1 {
  margin: 0.25rem 0 0;
  font-size: var(--fs-xl);
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.ac-back {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  transition: color 200ms ease;
}
.ac-back:hover { color: var(--primary-ink); }
.ac-back i, .ac-back svg { inline-size: 16px; block-size: 16px; }

/* ————— shared: order number / status pill ————— */
.ac-orderNum {
  font-weight: 700;
  font-size: var(--fs-sm);
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.ac-orderStatus {
  display: inline-flex;
  align-items: center;
  padding: 0.28rem 0.75rem;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
  white-space: nowrap;
  color: var(--muted);
  background: var(--surface-2);
}
.ac-orderStatus[data-status="pending_payment"],
.ac-orderStatus[data-status="processing"] {
  color: oklch(0.46 0.13 70);
  background: oklch(0.75 0.15 70 / 0.16);
}
.ac-orderStatus[data-status="paid"],
.ac-orderStatus[data-status="delivered"] {
  color: oklch(0.4 0.11 155);
  background: oklch(0.6 0.14 155 / 0.14);
}
.ac-orderStatus[data-status="shipped"] {
  color: var(--primary-ink);
  background: oklch(0.7 0.14 256 / 0.14);
}
.ac-orderStatus[data-status="cancelled"],
.ac-orderStatus[data-status="refunded"] {
  color: oklch(0.42 0.17 25);
  background: oklch(0.6 0.19 25 / 0.12);
}

/* ============================================================================
   LOGIN  (login.php)
   ========================================================================== */
.ac-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-block-size: calc(100vh - 74px);
  padding-block: 3rem;
}

.ac-card {
  inline-size: min(440px, 100%);
  padding: clamp(1.75rem, 4vw, 2.5rem);
  border-radius: var(--r-xl);
  text-align: center;
}

.ac-brandDot {
  display: grid;
  place-items: center;
  inline-size: 56px;
  block-size: 56px;
  margin-inline: auto;
  margin-block-end: 1.1rem;
  border-radius: 50%;
  color: var(--primary-ink);
  background: oklch(0.7 0.14 256 / 0.14);
  box-shadow: inset 0 1px 0 oklch(1 0 0 / 0.6);
}
.ac-brandDot svg { inline-size: 26px; block-size: 26px; }

.ac-title {
  margin: 0 0 0.5rem;
  font-size: var(--fs-lg);
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.ac-sub {
  margin: 0 0 1.4rem;
  color: var(--muted);
  font-size: var(--fs-sm);
  line-height: 1.8;
}
.ac-sub b { color: var(--ink); font-weight: 700; }

.ac-form { text-align: start; }
.ac-form .ac-field:last-of-type { margin-block-end: 1.3rem; }

.ac-altRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-block-start: 1.1rem;
  flex-wrap: wrap;
}
.ac-resend { margin: 0; }

.ac-legal {
  margin: 1.6rem 0 0;
  font-size: 0.76rem;
  color: var(--muted);
  line-height: 1.8;
}
.ac-legal a { color: var(--primary-ink); text-decoration: none; }
.ac-legal a:hover { text-decoration: underline; text-underline-offset: 2px; }

@media (max-width: 480px) {
  .ac-wrap { padding-block: 1.75rem; align-items: flex-start; }
  .ac-card { border-radius: var(--r-lg); }
}

/* ============================================================================
   DASHBOARD  (account.php)
   ========================================================================== */
.ac-dash {
  max-inline-size: 880px;
  padding-block: clamp(1.75rem, 4vw, 3rem) 4rem;
  display: grid;
  gap: 1.75rem;
}

.ac-dashHead {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.ac-avatar {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  inline-size: 56px;
  block-size: 56px;
  border-radius: 50%;
  color: var(--primary-ink);
  background: oklch(0.7 0.14 256 / 0.14);
  box-shadow: inset 0 1px 0 oklch(1 0 0 / 0.6);
}
.ac-avatar i, .ac-avatar svg { inline-size: 26px; block-size: 26px; }

.ac-dashWho { flex: 1 1 auto; min-inline-size: 0; }
.ac-dashWho h1 {
  margin: 0;
  font-size: var(--fs-md);
  font-weight: 800;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ac-dashWho p {
  margin: 0.15rem 0 0;
  font-size: var(--fs-sm);
  color: var(--muted);
}

.ac-logout { margin-inline-start: auto; flex-shrink: 0; }

/* tiles */
.ac-tiles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.9rem;
}
.ac-tile {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 1.15rem;
  border-radius: var(--r-lg);
  color: inherit;
  text-decoration: none;
  transition: transform var(--dur-glide) var(--spring-glide), box-shadow var(--dur-glide) var(--spring-glide);
}
.ac-tile:hover {
  transform: translateY(-3px);
  box-shadow:
    inset 0 1px 0 oklch(1 0 0 / 0.55),
    0 20px 36px -22px oklch(0.25 0.02 220 / 0.3);
}
.ac-tileIcon {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  inline-size: 44px;
  block-size: 44px;
  border-radius: var(--r-sm);
  color: var(--primary-ink);
  background: oklch(0.7 0.14 256 / 0.12);
}
.ac-tileIcon i, .ac-tileIcon svg { inline-size: 21px; block-size: 21px; }
.ac-tileBody {
  flex: 1 1 auto;
  min-inline-size: 0;
  display: grid;
  gap: 0.15rem;
}
.ac-tileBody strong {
  font-size: var(--fs-base);
  font-weight: 700;
  color: var(--ink);
}
.ac-tileBody em {
  font-style: normal;
  font-size: var(--fs-sm);
  color: var(--muted);
}
.ac-tileGo {
  flex-shrink: 0;
  inline-size: 16px;
  block-size: 16px;
  color: var(--muted);
  opacity: 0.6;
  /* icon is drawn for LTR "forward" (chevron-left); flip so it points to the
     RTL logical end, matching the tile's reading direction. */
  transform: scaleX(-1);
  transition: transform 240ms var(--spring-pop), opacity 240ms ease;
}
.ac-tile:hover .ac-tileGo { opacity: 1; transform: scaleX(-1) translateX(-3px); }

/* recent orders */
.ac-orderList {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.6rem;
}
.ac-orderRow {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.9rem 1.1rem;
  border-radius: var(--r-md);
}
.ac-orderRow .ac-orderNum { flex: 1 1 auto; min-inline-size: 0; }
.ac-orderTotal {
  flex-shrink: 0;
  font-weight: 700;
  color: var(--ink);
  margin-inline-start: auto;
}

@media (max-width: 720px) {
  .ac-tiles { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .ac-dashHead { gap: 0.85rem; }
  .ac-logout { inline-size: 100%; margin-inline-start: 0; order: 3; }
  .ac-logout .btn { inline-size: 100%; }
  .ac-orderRow { flex-wrap: wrap; }
}

/* ============================================================================
   ORDERS  (account-orders.php)
   ========================================================================== */
.ac-empty {
  display: grid;
  justify-items: center;
  gap: 0.9rem;
  padding: clamp(2.5rem, 6vw, 3.5rem) 1.5rem;
  border-radius: var(--r-xl);
  text-align: center;
}
.ac-emptyIcon {
  display: grid;
  place-items: center;
  inline-size: 60px;
  block-size: 60px;
  border-radius: 50%;
  color: var(--muted);
  background: var(--surface-2);
}
.ac-emptyIcon i, .ac-emptyIcon svg { inline-size: 28px; block-size: 28px; }
.ac-empty p { margin: 0; color: var(--muted); }

.ac-orders {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 1rem;
}
.ac-orderCard {
  padding: 1.15rem 1.25rem 1.3rem;
  border-radius: var(--r-lg);
}
.ac-orderCard__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-block-end: 0.85rem;
  border-block-end: 1px solid var(--line);
}
.ac-orderCard__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-block: 0.75rem;
  border-block-end: 1px solid var(--line);
  font-size: var(--fs-sm);
}
.ac-orderCard__meta time { color: var(--muted); }
.ac-orderCard__meta strong { color: var(--ink); font-weight: 700; }
.ac-orderCard:has(> .ac-orderCard__meta:last-child) .ac-orderCard__meta { border-block-end: 0; }

.ac-orderItems {
  list-style: none;
  margin: 0;
  padding-block-start: 0.6rem;
  display: grid;
  gap: 0.5rem;
}
.ac-orderItems li {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  font-size: var(--fs-sm);
}
.ac-oiQty {
  flex-shrink: 0;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.ac-oiName {
  flex: 1 1 auto;
  min-inline-size: 0;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ac-oiPrice {
  flex-shrink: 0;
  color: var(--muted);
}

@media (max-width: 560px) {
  .ac-orderCard__meta { align-items: flex-start; flex-direction: column; gap: 0.25rem; }
}

/* ============================================================================
   PROFILE  (account-profile.php) — reuses .ac-card/.ac-form/.ac-field/.ac-input
   ============================================================================ */
.ac-dash > .ac-card.ac-form {
  padding: clamp(1.5rem, 4vw, 2.25rem);
  text-align: start;
  max-inline-size: 560px;
}
.ac-dash > .ac-card.ac-form .ac-field:last-of-type { margin-block-end: 1.4rem; }

/* ————— defensive: keep the anti-bot honeypot field fully off-screen ————— */
.honeypot {
  position: absolute;
  inset-inline-start: -9999px;
  inline-size: 1px;
  block-size: 1px;
  overflow: hidden;
}

@media (prefers-reduced-motion: reduce) {
  .ac-tile:hover,
  .ac-tile:hover .ac-tileGo {
    transform: none;
  }
}
