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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: 48px;
  padding: 0 var(--space-5);
  border-radius: var(--radius-md);
  font-size: var(--fs-md);
  font-weight: 700;
  white-space: nowrap;
  transition: transform var(--dur-fast) var(--ease-standard),
    box-shadow var(--dur-fast) var(--ease-standard),
    background var(--dur-fast) var(--ease-standard),
    opacity var(--dur-fast) var(--ease-standard);
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; transform: none; }

.btn--primary {
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-600));
  color: var(--text-on-primary);
  box-shadow: var(--shadow-primary);
}
.btn--primary:hover:not(:disabled) { box-shadow: 0 10px 26px rgba(11, 95, 165, 0.36); }

.btn--secondary {
  background: var(--color-primary-100);
  color: var(--color-primary-700);
}

.btn--ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn--ghost:hover { background: var(--bg-surface-muted); }

.btn--danger {
  background: var(--color-danger-100);
  color: var(--color-danger);
}

.btn--block { width: 100%; }
.btn--sm { height: 38px; padding: 0 var(--space-4); font-size: var(--fs-sm); border-radius: var(--radius-sm); }
.btn--icon { width: 44px; height: 44px; padding: 0; border-radius: var(--radius-pill); }

.btn .spinner { margin-inline-end: var(--space-1); }

/* Inputs --------------------------------------------------------------- */

.field { display: flex; flex-direction: column; gap: var(--space-2); margin-bottom: var(--space-4); }
.field__label { font-size: var(--fs-sm); font-weight: 600; color: var(--text-secondary); }

.field__control {
  position: relative;
  display: flex;
  align-items: center;
}

.input, .textarea, .select {
  width: 100%;
  background: var(--bg-surface);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0 var(--space-4);
  height: 50px;
  font-size: var(--fs-base);
  color: var(--text-primary);
  transition: border-color var(--dur-fast) var(--ease-standard), box-shadow var(--dur-fast) var(--ease-standard);
}
.textarea { height: auto; padding: var(--space-3) var(--space-4); resize: vertical; min-height: 90px; }
.input::placeholder, .textarea::placeholder { color: var(--text-tertiary); }
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 4px var(--color-primary-100);
}
.input--error { border-color: var(--color-danger); }
.field__hint { font-size: var(--fs-xs); color: var(--text-tertiary); }
.field__error { font-size: var(--fs-xs); color: var(--color-danger); font-weight: 600; }

.field__suffix-btn {
  position: absolute;
  inset-inline-end: var(--space-2);
  color: var(--text-tertiary);
  padding: var(--space-2);
  border-radius: var(--radius-pill);
}

/* Cards ----------------------------------------------------------------- */

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--space-4);
}

.card--interactive { transition: transform var(--dur-fast) var(--ease-standard), box-shadow var(--dur-fast) var(--ease-standard); }
.card--interactive:active { transform: scale(0.98); box-shadow: var(--shadow-md); }

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

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px var(--space-3);
  border-radius: var(--radius-pill);
  font-size: var(--fs-xs);
  font-weight: 700;
}
.badge--info { background: var(--color-info-100); color: var(--color-info); }
.badge--success { background: var(--color-success-100); color: var(--color-success); }
.badge--danger { background: var(--color-danger-100); color: var(--color-danger); }
.badge--warning { background: var(--color-warning-100); color: var(--color-warning); }
.badge--neutral { background: var(--bg-surface-muted); color: var(--text-secondary); }

.chip {
  display: inline-flex;
  align-items: center;
  height: 34px;
  padding: 0 var(--space-4);
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  font-weight: 600;
  transition: all var(--dur-fast) var(--ease-standard);
}
.chip--selected { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }

/* Product Card -------------------------------------------------------- */

.product-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform var(--dur-fast) var(--ease-standard), box-shadow var(--dur-fast) var(--ease-standard);
}
.product-card:active { transform: scale(0.97); }
.product-card__image {
  aspect-ratio: 1;
  background: var(--bg-surface-muted);
  display: grid;
  place-items: center;
  overflow: hidden;
}
.product-card__image img { width: 100%; height: 100%; object-fit: cover; }
.product-card__image .icon-placeholder { color: var(--text-tertiary); }
.product-card__body { padding: var(--space-3); display: flex; flex-direction: column; gap: 4px; }
.product-card__name { font-weight: 700; font-size: var(--fs-sm); line-height: 1.35; min-height: 2.6em; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.product-card__meta { font-size: var(--fs-xs); color: var(--text-tertiary); }
.product-card__price { font-weight: 800; color: var(--color-primary); font-size: var(--fs-md); margin-top: 2px; }

/* Icon placeholder ------------------------------------------------------- */
.icon-placeholder { width: 40%; height: 40%; opacity: 0.5; }

/* List rows --------------------------------------------------------- */

.row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  transition: background var(--dur-fast) var(--ease-standard), transform var(--dur-fast) var(--ease-standard);
}
.row + .row { margin-top: var(--space-2); }
.row--interactive:active { transform: scale(0.98); background: var(--bg-surface-muted); }
.row__icon {
  width: 42px; height: 42px; border-radius: var(--radius-pill);
  background: var(--color-primary-100); color: var(--color-primary);
  display: grid; place-items: center; flex-shrink: 0;
}
.row__body { flex: 1; min-width: 0; }
.row__title { font-weight: 700; font-size: var(--fs-base); color: var(--text-primary); }
.row__subtitle { font-size: var(--fs-sm); color: var(--text-secondary); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row__trailing { color: var(--text-tertiary); flex-shrink: 0; }

/* Bottom nav ------------------------------------------------------------- */

.bottom-nav {
  position: sticky;
  bottom: 0;
  z-index: 20;
  display: flex;
  background: color-mix(in srgb, var(--bg-surface) 94%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border-subtle);
  padding-bottom: var(--safe-bottom);
}
.bottom-nav__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: var(--space-2) 0 calc(var(--space-2) - 2px);
  color: var(--text-tertiary);
  font-size: 11px;
  font-weight: 700;
  position: relative;
  transition: color var(--dur-fast) var(--ease-standard);
}
.bottom-nav__item.active { color: var(--color-primary); }
.bottom-nav__item .badge-dot {
  position: absolute; top: 2px; inset-inline-end: calc(50% - 18px);
  width: 8px; height: 8px; border-radius: 50%; background: var(--color-danger);
  border: 2px solid var(--bg-surface);
}

/* FAB --------------------------------------------------------------- */
.fab {
  position: fixed;
  inset-inline-end: max(var(--space-5), calc((100vw - 560px) / 2 + var(--space-5)));
  bottom: calc(var(--space-6) + var(--safe-bottom));
  width: 58px; height: 58px; border-radius: var(--radius-pill);
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-600));
  color: #fff;
  display: grid; place-items: center;
  box-shadow: var(--shadow-primary);
  z-index: 15;
  transition: transform var(--dur-fast) var(--ease-standard);
}
.fab:active { transform: scale(0.92); }

/* Empty state --------------------------------------------------------- */
.empty-state {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  gap: var(--space-3); padding: var(--space-8) var(--space-5); color: var(--text-secondary);
}
.empty-state__icon { color: var(--text-tertiary); opacity: 0.7; }
.empty-state__title { font-weight: 700; font-size: var(--fs-md); color: var(--text-primary); }

/* Spinner ------------------------------------------------------------- */
.spinner {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2.5px solid rgba(255,255,255,0.4); border-top-color: #fff;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
.spinner--primary { border: 2.5px solid var(--color-primary-100); border-top-color: var(--color-primary); }
.spinner--lg { width: 34px; height: 34px; border-width: 3px; }

/* Toast / snackbar ------------------------------------------------------ */
.toast-host {
  position: fixed;
  left: 50%;
  bottom: calc(var(--space-6) + var(--safe-bottom));
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  width: min(92vw, 460px);
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  background: #1c2836;
  color: #fff;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--fs-sm);
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.toast--error { background: var(--color-danger); }
.toast--success { background: var(--color-success); }

/* Dialog / sheet ------------------------------------------------------- */
.overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(10, 16, 24, 0.5);
  display: flex; align-items: flex-end; justify-content: center;
}
.overlay.overlay--center { align-items: center; padding: var(--space-5); }

.sheet {
  width: 100%;
  max-width: 560px;
  background: var(--bg-surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: var(--space-5) var(--space-5) calc(var(--space-6) + var(--safe-bottom));
  max-height: 86vh;
  overflow-y: auto;
}
.sheet__handle { width: 40px; height: 4px; border-radius: 2px; background: var(--border-strong); margin: 0 auto var(--space-4); }

.dialog {
  width: 100%;
  max-width: 380px;
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-lg);
}
.dialog__title { font-size: var(--fs-lg); font-weight: 800; margin-bottom: var(--space-2); }
.dialog__body { color: var(--text-secondary); font-size: var(--fs-base); margin-bottom: var(--space-5); }
.dialog__actions { display: flex; gap: var(--space-2); justify-content: flex-end; }

/* Progress stepper (orders) --------------------------------------------- */
.stepper { display: flex; flex-direction: column; }
.step {
  display: flex; gap: var(--space-3); position: relative;
}
.step__rail { display: flex; flex-direction: column; align-items: center; }
.step__dot {
  width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center; flex-shrink: 0;
  background: var(--bg-surface-muted); color: var(--text-tertiary);
  border: 2px solid var(--border-subtle);
  transition: all var(--dur-base) var(--ease-standard);
}
.step__dot.done { background: var(--color-success); border-color: var(--color-success); color: #fff; }
.step__dot.current { background: var(--color-primary); border-color: var(--color-primary); color: #fff; box-shadow: 0 0 0 5px var(--color-primary-100); }
.step__line { width: 2px; flex: 1; background: var(--border-subtle); min-height: 26px; }
.step__line.done { background: var(--color-success); }
.step__content { padding-bottom: var(--space-5); flex: 1; }
.step__label { font-weight: 700; font-size: var(--fs-base); }
.step__label.pending { color: var(--text-tertiary); font-weight: 600; }

/* Avatar --------------------------------------------------------------- */
.avatar {
  width: 46px; height: 46px; border-radius: 50%;
  background: var(--color-primary-100); color: var(--color-primary);
  display: grid; place-items: center; font-weight: 800; overflow: hidden; flex-shrink: 0;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar--lg { width: 84px; height: 84px; font-size: var(--fs-xl); }

/* Divider ---------------------------------------------------------------- */
.divider { height: 1px; background: var(--border-subtle); margin: var(--space-4) 0; }

/* Section heading ------------------------------------------------------ */
.section-title { font-size: var(--fs-lg); font-weight: 800; margin-bottom: var(--space-3); }

/* Skeleton --------------------------------------------------------------- */
.skeleton {
  background: linear-gradient(100deg, var(--bg-surface-muted) 30%, var(--border-subtle) 50%, var(--bg-surface-muted) 70%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  border-radius: var(--radius-md);
}

/* Chat bubbles ----------------------------------------------------------- */
.bubble-row { display: flex; margin-bottom: var(--space-3); }
.bubble-row--user { justify-content: flex-start; }
.bubble-row--assistant { justify-content: flex-end; }
.bubble {
  max-width: 78%;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  font-size: var(--fs-base);
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  /* Chat-only, by request -- the rest of the app keeps --font-family
     (Cairo). Times New Roman has no Arabic glyphs, so Arabic text in a
     bubble automatically falls back to the browser's own Arabic font
     (standard per-script font substitution); only Latin letters/digits
     (product codes, prices, English replies) actually render in it. */
  font-family: "Times New Roman", Times, serif;
}
.bubble--user { background: var(--color-primary); color: #fff; border-bottom-left-radius: 4px; }
.bubble--assistant { background: var(--bg-surface); border: 1px solid var(--border-subtle); border-bottom-right-radius: 4px; }
.bubble--failed { border: 1.5px solid var(--color-danger); }
.bubble img { border-radius: var(--radius-sm); margin-bottom: var(--space-2); max-height: 220px; object-fit: cover; }
.bubble__time { font-size: 10.5px; opacity: 0.65; margin-top: 4px; }
.typing-dots { display: inline-flex; gap: 4px; align-items: center; padding: var(--space-2) 0; }
.typing-dots span { width: 6px; height: 6px; border-radius: 50%; background: var(--text-tertiary); animation: typing 1.2s ease-in-out infinite; }
.typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.typing-dots span:nth-child(3) { animation-delay: 0.3s; }
