/* Maktaba lite — additions on top of maktaba-theme.css.
   Only what the shared theme doesn't already cover. */

/* ---- page header with an action button on the far side ---- */
.page-header.with-actions {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.message-stack { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }

/* ---- Django's {{ form.as_div }} output, styled like .form-group ---- */
.theme-form > div { margin-bottom: 16px; }
.theme-form label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--gray-dark);
  margin-bottom: 6px;
}
.theme-form .helptext {
  display: block;
  font-size: 11px;
  color: var(--gray-light);
  margin-top: 5px;
}
.theme-form ul.errorlist,
ul.errorlist {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  font-size: 11px;
  color: #dc2626;
}
select.form-input { appearance: none; background-image: none; }
textarea.form-input { resize: vertical; }

/* ---- order status badges, one per Order.Status value ---- */
.badge.in_delivery { background: rgba(245, 158, 11, 0.12); color: #d97706; }
.badge.delivered { background: rgba(34, 197, 94, 0.12); color: #16a34a; }
.badge.not_delivered { background: rgba(239, 68, 68, 0.12); color: #dc2626; }
.badge.cancelled { background: var(--gray-hover); color: var(--gray); }
.badge.low { background: rgba(239, 68, 68, 0.12); color: #dc2626; }
.badge-lg { font-size: 13px; padding: 7px 16px; }

/* ---- filter chips (status tabs) ---- */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  padding: 7px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--gray-border);
  background: var(--white-pure);
  color: var(--gray);
  font-size: 12px;
  font-weight: 500;
  text-decoration: none;
  transition: var(--transition);
}
.chip:hover { background: var(--gray-hover); }
.chip.active { background: var(--brand-orange); border-color: var(--brand-orange); color: #fff; }

/* ---- numeric table cells ---- */
.table td.num, .table th.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tfoot th {
  padding: 12px 16px;
  text-align: right;
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  background: var(--white);
  border-top: 1px solid var(--gray-border);
}
.kv th { width: 40%; color: var(--gray); font-weight: 500; }

/* ---- revenue bar chart, plain CSS ---- */
.chart {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 160px;
  padding-top: 8px;
  direction: ltr;
}
.chart .bar {
  flex: 1;
  min-width: 3px;
  min-height: 2px;
  background: var(--brand-orange);
  border-radius: 3px 3px 0 0;
  opacity: .85;
  transition: var(--transition);
}
.chart .bar:hover { opacity: 1; }
.chart-axis {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--gray-light);
  margin-top: 8px;
  direction: ltr;
}

/* ---- delivery queue cards ---- */
.queue-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.queue-meta { font-size: 13px; color: var(--gray); line-height: 1.9; }
.queue-meta i { color: var(--brand-orange); width: 18px; }
.queue-items { list-style: none; margin: 12px 0 0; padding: 0; font-size: 13px; }
.queue-items li { padding: 6px 0; border-top: 1px dashed var(--gray-border); }

/* ---- login ---- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg-main);
}
.login-box { width: 100%; max-width: 380px; }
.login-brand { text-align: center; margin-bottom: 22px; }
.login-brand .logo {
  width: 56px; height: 56px; margin: 0 auto 12px;
  border-radius: var(--radius-md);
  background: var(--gradient-orange);
  color: #fff; font-size: 26px;
  display: flex; align-items: center; justify-content: center;
}
.login-brand h1 { font-size: 24px; font-weight: 600; color: var(--primary); }
.login-brand p { font-size: 13px; color: var(--gray); }

/* ---- misc ---- */
.muted { color: var(--gray); font-size: 12px; }
.ltr { direction: ltr; unicode-bidi: embed; }
.form-note { font-size: 12px; color: var(--gray); margin-top: 12px; }
.stat-card.compact .stat-value { font-size: 22px; }
a.stat-card { display: block; text-decoration: none; }

@media (max-width: 768px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* ---- purchase order status badges ---- */
.badge.ordered { background: rgba(59, 130, 246, 0.12); color: #2563eb; }
.badge.received { background: rgba(34, 197, 94, 0.12); color: #16a34a; }

/* ---- cart quantity stepper ---- */
.qty-form { display: flex; gap: 6px; align-items: center; }
.qty-form input { width: 78px; padding: 6px 8px; font-size: 13px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn[disabled]:hover { filter: none; }
.row-actions { display: flex; gap: 6px; align-items: center; justify-content: flex-end; }

/* ---- add-stock live preview ---- */
.preview {
  border: 1px dashed var(--gray-border);
  border-radius: var(--radius);
  padding: 14px 16px;
  background: var(--white);
  transition: var(--transition);
}
.preview.active { border-color: var(--brand-orange); background: var(--brand-orange-light); }
.preview-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 13px;
  color: var(--gray);
  padding: 4px 0;
}
.preview-row strong { color: var(--gray-dark); font-variant-numeric: tabular-nums; }
.preview-row.total {
  border-top: 1px solid var(--gray-border);
  margin-top: 6px;
  padding-top: 10px;
  font-size: 14px;
}
.preview-row.total span { color: var(--gray-dark); font-weight: 500; }
.preview-row.total strong { font-size: 20px; font-weight: 700; color: var(--brand-orange); }

/* ---- item thumbnails in tables ---- */
.thumb {
  width: 34px; height: 34px; border-radius: 8px; object-fit: cover;
  background: var(--gray-hover); border: 1px solid var(--gray-border); vertical-align: middle;
}
.cell-item { display: flex; align-items: center; gap: 10px; }


/* ---- order kind badges ---- */
.badge.kind-delivery { background: var(--brand-orange-light); color: var(--brand-orange); }
.badge.kind-cash { background: rgba(34, 197, 94, .12); color: #16a34a; }
.badge.kind-return { background: rgba(245, 158, 11, .12); color: #d97706; }

/* ---- side-by-side fields (الوسيط destination picker) ---- */
.form-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.form-row .form-group { margin-bottom: 12px; }
@media (max-width: 700px) { .form-row { grid-template-columns: 1fr; } }

/* ---- inline row actions (edit / delete) ---- */
.row-actions { display: flex; gap: 6px; justify-content: flex-end; align-items: center; }
.row-actions form { display: inline; }
