/* Reusable production components */

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: var(--fs-md);
  line-height: 1;
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast), border-color var(--t-fast);
  white-space: nowrap;
  border: 1px solid transparent;
  user-select: none;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn .lucide { width: 16px; height: 16px; flex-shrink: 0; }

.btn-primary { background: var(--c-primary); color: var(--c-primary-text); }
.btn-primary:hover:not(:disabled) { background: var(--c-primary-hover); }
.btn-primary:active:not(:disabled) { background: var(--c-primary-active); }

.btn-accent { background: var(--c-accent); color: var(--c-accent-text); }
.btn-accent:hover:not(:disabled) { background: var(--c-accent-hover); }

.btn-dark { background: var(--c-text); color: var(--c-bg); }
.btn-dark:hover:not(:disabled) { background: color-mix(in srgb, var(--c-text) 85%, transparent); }

.btn-ghost { background: transparent; border-color: var(--c-border); color: var(--c-text); }
.btn-ghost:hover:not(:disabled) { background: var(--c-surface); border-color: var(--c-border-2); }

.btn-subtle { background: var(--c-surface-2); color: var(--c-text); }
.btn-subtle:hover:not(:disabled) { background: var(--c-border); }

.btn-danger { background: var(--c-danger); color: white; }
.btn-danger:hover:not(:disabled) { background: var(--jp-red-700); }

.btn-icon { padding: 8px; min-width: 36px; height: 36px; }
.btn-sm { padding: 6px 12px; font-size: var(--fs-sm); }
.btn-lg { padding: 14px 24px; font-size: var(--fs-lg); }
.btn-block { width: 100%; }

/* ── Inputs ──────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: var(--sp-2); }
.field label { font-size: var(--fs-sm); font-weight: 600; color: var(--c-text-2); }
.field .hint { font-size: var(--fs-xs); color: var(--c-text-3); }
.field .error { font-size: var(--fs-xs); color: var(--c-danger); display: none; }
.field.has-error .error { display: block; }
.field.has-error .input,
.field.has-error .select { border-color: var(--c-danger); }

.input, .select, .textarea {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--c-border);
  background: var(--c-bg);
  color: var(--c-text);
  font-size: var(--fs-md);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  text-align: start;
}
.input::placeholder, .textarea::placeholder { color: var(--c-muted); }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--c-primary) 18%, transparent);
}
.input-group { position: relative; }
.input-group .input { padding-inline-start: 40px; }
.input-group .input-icon {
  position: absolute;
  inset-inline-start: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--c-text-3);
  width: 16px; height: 16px;
}
.input-group .input-suffix {
  position: absolute;
  inset-inline-end: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--c-text-3);
}

.checkbox, .radio {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  cursor: pointer;
  font-size: var(--fs-sm);
  color: var(--c-text-2);
}
.checkbox input, .radio input {
  width: 16px; height: 16px;
  accent-color: var(--c-primary);
  cursor: pointer;
}

/* ── Cards ───────────────────────────────────────────────── */
.card {
  background: var(--c-bg);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}
.card-pad { padding: var(--sp-5); }
.card-pad-lg { padding: var(--sp-6); }
.card-hd {
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--c-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
}
.card-bd { padding: var(--sp-5); }

/* ── Pills / Badges ──────────────────────────────────────── */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: var(--fs-xs);
  font-weight: 600;
  background: var(--c-surface-2);
  color: var(--c-text-2);
  border: 1px solid transparent;
  white-space: nowrap;
}
.pill .lucide { width: 12px; height: 12px; }
.pill-success { background: var(--c-success-bg); color: var(--c-success); }
.pill-warning { background: var(--c-warning-bg); color: var(--c-warning); }
.pill-danger  { background: var(--c-danger-bg); color: var(--c-danger); }
.pill-info    { background: var(--c-info-bg); color: var(--c-info); }
.pill-outline { background: transparent; border-color: var(--c-border); }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--c-border-2); }
.dot-success { background: var(--c-success); }
.dot-warning { background: var(--c-warning); }
.dot-danger  { background: var(--c-danger); }
.dot-live    { background: var(--c-success); animation: pulse 1.4s ease-in-out infinite; box-shadow: 0 0 0 0 var(--c-success); }

/* ── Tables ──────────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 12px 14px; text-align: start; vertical-align: middle; }
.table th {
  background: var(--c-surface);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 700;
  color: var(--c-text-2);
  border-bottom: 1px solid var(--c-border);
  position: sticky;
  top: 0;
  z-index: 1;
}
.table tbody tr { border-bottom: 1px solid var(--c-border); transition: background var(--t-fast); }
.table tbody tr:hover { background: var(--c-surface); }
.table tbody tr.selected { background: color-mix(in srgb, var(--c-primary) 6%, var(--c-bg)); }

/* ── Tabs ────────────────────────────────────────────────── */
.tabs {
  display: inline-flex;
  background: var(--c-surface-2);
  padding: 4px;
  border-radius: var(--radius-sm);
  gap: 2px;
}
.tab {
  padding: 7px 14px;
  border-radius: 6px;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--c-text-2);
  cursor: pointer;
  transition: all var(--t-fast);
}
.tab[aria-selected="true"] {
  background: var(--c-bg);
  color: var(--c-text);
  box-shadow: var(--shadow-xs);
}

.tabs-line { display: flex; gap: var(--sp-5); border-bottom: 1px solid var(--c-border); }
.tab-line {
  padding: 12px 4px;
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--c-text-2);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all var(--t-fast);
}
.tab-line[aria-selected="true"] { color: var(--c-primary); border-bottom-color: var(--c-primary); }

/* ── Toast ───────────────────────────────────────────────── */
.toast-stack {
  position: fixed;
  inset-block-end: 24px;
  inset-inline-end: 24px;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  z-index: 9000;
  pointer-events: none;
}
.toast {
  background: var(--c-text);
  color: var(--c-bg);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  pointer-events: auto;
  animation: fade-in var(--t-med) var(--ease) both;
  max-width: 360px;
}
.toast .lucide { width: 16px; height: 16px; flex-shrink: 0; }
.toast.success { background: var(--c-success); color: white; }
.toast.danger  { background: var(--c-danger); color: white; }
.toast.warning { background: var(--c-warning); color: var(--c-text); }

/* ── Modal ───────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--c-overlay);
  backdrop-filter: blur(4px);
  z-index: 8000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-4);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-med) var(--ease);
}
.modal-backdrop.open { opacity: 1; pointer-events: auto; }
.modal {
  background: var(--c-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 460px;
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  transform: translateY(8px) scale(.98);
  transition: transform var(--t-med) var(--ease);
  overflow: hidden;
}
.modal-backdrop.open .modal { transform: none; }
.modal-hd { padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--c-border); display: flex; align-items: center; justify-content: space-between; }
.modal-bd { padding: var(--sp-5); overflow-y: auto; }
.modal-ft { padding: var(--sp-4) var(--sp-5); border-top: 1px solid var(--c-border); display: flex; gap: var(--sp-2); justify-content: flex-end; }

/* ── Dropdown ────────────────────────────────────────────── */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  inset-inline-end: 0;
  min-width: 200px;
  background: var(--c-bg);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 6px;
  z-index: 100;
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition: opacity var(--t-fast), transform var(--t-fast);
}
.dropdown.open .dropdown-menu { opacity: 1; transform: none; pointer-events: auto; }
.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 8px 10px;
  border-radius: 6px;
  font-size: var(--fs-sm);
  color: var(--c-text);
  cursor: pointer;
  transition: background var(--t-fast);
}
.dropdown-item:hover { background: var(--c-surface); }
.dropdown-item .lucide { width: 14px; height: 14px; color: var(--c-text-3); }

/* ── Empty / Error states ────────────────────────────────── */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--sp-12) var(--sp-6);
  gap: var(--sp-3);
  color: var(--c-text-2);
}
.empty .lucide { width: 48px; height: 48px; color: var(--c-muted); }
.empty h3 { color: var(--c-text); }

/* ── Theme toggle ───────────────────────────────────────── */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--c-border);
  background: var(--c-bg);
  color: var(--c-text-2);
  cursor: pointer;
  transition: all var(--t-fast);
}
.theme-toggle:hover { color: var(--c-text); border-color: var(--c-border-2); }

/* ── Heritage flag accent (decorative bar on hero/auth) ─── */
.flag-bar {
  display: flex;
  height: 4px;
  border-radius: 2px;
  overflow: hidden;
}
.flag-bar > span { flex: 1; }
.flag-bar > span:nth-child(1) { background: var(--jp-black); }
.flag-bar > span:nth-child(2) { background: var(--jp-white); border-block: 1px solid var(--c-border); }
.flag-bar > span:nth-child(3) { background: var(--jp-green); }
.flag-bar > span:nth-child(4) { background: var(--jp-red); }

/* Spinner */
.spin { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; }

/* ── Brand wordmark "مال · كاردز" ─────────────────────────
   Two-tone heritage split: مال in white, كاردز in red,
   separated by a green dot. Slight slant + extra tracking
   give it a unique silhouette versus normal body copy. */
.brand-mark {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  font-weight: 800;
  font-style: italic;
  text-shadow: 0 1px 0 rgba(0,0,0,0.25);
}
.brand-mark-mal {
  color: #ffffff;
  border-bottom: 2px solid var(--jp-green);
  padding-bottom: 1px;
}
.brand-mark-dot {
  color: var(--jp-green);
  font-weight: 900;
  transform: translateY(-2px);
  display: inline-block;
}
.brand-mark-cards {
  color: var(--jp-red);
  background: linear-gradient(180deg, #ff4d6a 0%, var(--jp-red) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 1px 0 rgba(0,0,0,0.3));
}
