/* Zaabel Admin — Sage Bazaar theme overrides on top of Bootstrap 5
   Mirrors web/app/globals.css token set so admin and storefront share an identity.
   Loaded after bootstrap[.rtl].min.css so these win.
*/

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Arabic:wght@400;500;600;700&family=IBM+Plex+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500&display=swap');

:root {
  /* Sage Bazaar tokens */
  --green-900: #2d4a36;
  --green-700: #3d6448;
  --green-600: #4a7c59;
  --green-500: #6b9b78;
  --green-400: #a4c3b2;
  --green-300: #c8dccf;
  --green-200: #dde9e0;
  --green-100: #eaf4f4;

  --beige-100: #f6f1e9;
  --beige-50:  #faf6ef;
  --off-white: #fdfcfa;
  --paper:     #fffdf8;

  --coral-600: #d8593b;
  --coral-500: #e76f51;
  --coral-100: #fce6df;
  --amber-500: #e4a629;
  --amber-100: #fbeccc;

  --ink-900: #1a1f1c;
  --ink-700: #2d3530;
  --ink-500: #5b665e;
  --ink-400: #7a857d;
  --ink-300: #aab2ac;

  --line-100: rgba(45, 53, 48, 0.08);
  --line-200: rgba(45, 53, 48, 0.14);
  --line-300: rgba(45, 53, 48, 0.22);

  /* Bootstrap variable overrides */
  --bs-primary: var(--green-600);
  --bs-primary-rgb: 74, 124, 89;
  --bs-secondary: var(--green-400);
  --bs-secondary-rgb: 164, 195, 178;
  --bs-success: var(--green-700);
  --bs-success-rgb: 61, 100, 72;
  --bs-danger: var(--coral-600);
  --bs-danger-rgb: 216, 89, 59;
  --bs-warning: var(--amber-500);
  --bs-warning-rgb: 228, 166, 41;
  --bs-info: var(--green-500);
  --bs-info-rgb: 107, 155, 120;

  --bs-body-bg: var(--off-white);
  --bs-body-color: var(--ink-900);
  --bs-border-color: var(--line-200);
  --bs-border-radius: 10px;
  --bs-border-radius-sm: 6px;
  --bs-border-radius-lg: 14px;

  --bs-link-color: var(--green-700);
  --bs-link-hover-color: var(--green-900);

  --bs-font-sans-serif: "IBM Plex Sans Arabic", "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --bs-font-monospace: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

html[dir="ltr"] body { font-family: "IBM Plex Sans", "IBM Plex Sans Arabic", system-ui, sans-serif; }
html[dir="rtl"] body { font-family: "IBM Plex Sans Arabic", "IBM Plex Sans", system-ui, sans-serif; }

body {
  background: var(--off-white);
  color: var(--ink-900);
  -webkit-font-smoothing: antialiased;
}

.num { font-variant-numeric: tabular-nums; font-feature-settings: 'tnum' on; }

/* Buttons */
.btn-primary { --bs-btn-bg: var(--green-600); --bs-btn-border-color: var(--green-600); --bs-btn-hover-bg: var(--green-700); --bs-btn-hover-border-color: var(--green-700); --bs-btn-active-bg: var(--green-900); }
.btn-outline-primary { --bs-btn-color: var(--green-700); --bs-btn-border-color: var(--green-600); --bs-btn-hover-bg: var(--green-100); --bs-btn-hover-color: var(--green-900); --bs-btn-hover-border-color: var(--green-700); }
.btn-outline-secondary { --bs-btn-color: var(--ink-700); --bs-btn-border-color: var(--line-300); --bs-btn-hover-bg: var(--beige-100); --bs-btn-hover-color: var(--ink-900); --bs-btn-hover-border-color: var(--line-300); }
.btn-danger { --bs-btn-bg: var(--coral-600); --bs-btn-border-color: var(--coral-600); --bs-btn-hover-bg: var(--coral-500); --bs-btn-hover-border-color: var(--coral-500); }

/* Forms */
.form-control, .form-select { border-color: var(--line-200); }
.form-control:focus, .form-select:focus { border-color: var(--green-600); box-shadow: 0 0 0 0.2rem rgba(74,124,89,0.15); }
.form-control.is-invalid { border-color: var(--coral-500); }
.form-control.is-invalid:focus { box-shadow: 0 0 0 0.2rem rgba(216,89,59,0.15); }
.form-label { font-size: .8rem; font-weight: 600; color: var(--ink-700); margin-bottom: .35rem; text-transform: uppercase; letter-spacing: .03em; }

/* Cards */
.card { border-color: var(--line-100); }
.card-kpi { border-top: 3px solid var(--green-600); }
.card-kpi .kpi-label { color: var(--ink-400); font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; }
.card-kpi .kpi-value { font-size: 1.75rem; font-weight: 700; color: var(--ink-900); line-height: 1.1; }
.card-kpi .kpi-trend { font-size: .8rem; }
.card-kpi.kpi-amber { border-top-color: var(--amber-500); }
.card-kpi.kpi-coral { border-top-color: var(--coral-500); }
.card-kpi.kpi-ink   { border-top-color: var(--ink-700); }

/* Tables */
.table > :not(caption) > * > * { padding: .65rem .75rem; }
.table thead th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-400); background: var(--paper); border-bottom-color: var(--line-200); font-weight: 600; }
.table-hover > tbody > tr:hover > * { background: var(--beige-50); }
.table .row-actions { opacity: 0; transition: opacity .15s; }
.table tbody tr:hover .row-actions { opacity: 1; }

/* Status pills (mirror storefront StatusPill colours) */
.status-pill { display: inline-flex; align-items: center; padding: .15rem .55rem; border-radius: 999px; font-size: .72rem; font-weight: 600; white-space: nowrap; }
.status-pill.s-Pending   { background: var(--beige-100); color: var(--ink-700); }
.status-pill.s-Confirmed { background: var(--green-100); color: var(--green-700); }
.status-pill.s-Preparing { background: var(--amber-100); color: #3a2a00; }
.status-pill.s-Shipped   { background: var(--green-200); color: var(--green-900); }
.status-pill.s-Delivered { background: var(--green-600); color: white; }
.status-pill.s-Cancelled,
.status-pill.s-Returned  { background: var(--coral-100); color: var(--coral-600); text-transform: uppercase; letter-spacing: .04em; }

/* Tier pill (loyalty) */
.tier-pill { display: inline-flex; align-items: center; padding: .2rem .55rem; border-radius: 999px; font-size: .72rem; font-weight: 600; }
.tier-pill.t-Bronze   { background: var(--amber-100); color: #3a2a00; }
.tier-pill.t-Silver   { background: var(--line-200); color: var(--ink-700); }
.tier-pill.t-Gold     { background: var(--amber-500); color: white; }
.tier-pill.t-Platinum { background: var(--green-900); color: white; }

/* Sidebar */
.zb-sidebar {
  width: 240px;
  background: var(--paper);
  border-inline-end: 1px solid var(--line-100);
  min-height: 100vh;
  padding: 1rem .75rem;
}
.zb-sidebar .brand { display: flex; align-items: center; gap: .5rem; padding: .5rem .75rem 1.25rem; }
.brand-logo { width: 36px; height: 36px; border-radius: 10px; object-fit: contain; background: rgba(255,255,255,.96); padding: .25rem; box-shadow: 0 8px 20px rgba(14, 20, 16, .18); flex-shrink: 0; }
.zb-sidebar .brand-mark { width: 28px; height: 28px; border-radius: 8px; background: var(--green-700); color: white; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 1.1rem; position: relative; }
.zb-sidebar .brand-mark::after { content: ''; position: absolute; top: -2px; inset-inline-end: -2px; width: 8px; height: 8px; background: var(--amber-500); border-radius: 50% 50% 0 50%; transform: rotate(45deg); }
.zb-sidebar .brand-name { font-weight: 700; line-height: 1; color: var(--ink-900); }
.zb-sidebar .brand-name small { display: block; color: var(--ink-400); font-size: .65rem; margin-top: 2px; font-weight: 400; }
.zb-sidebar .nav-section { font-size: .65rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-400); padding: 1.25rem .75rem .35rem; }
.zb-sidebar .nav-link { color: var(--ink-700); padding: .5rem .75rem; border-radius: 6px; display: flex; align-items: center; gap: .5rem; font-size: .9rem; }
.zb-sidebar .nav-link:hover { background: var(--beige-50); color: var(--green-700); }
.zb-sidebar .nav-link.active { background: var(--green-100); color: var(--green-700); font-weight: 600; }
.zb-sidebar .locale-toggle { margin-top: 1rem; padding: .5rem .75rem; font-size: .8rem; color: var(--ink-500); }

/* Topbar */
.zb-topbar { height: 56px; background: white; border-bottom: 1px solid var(--line-100); display: flex; align-items: center; padding: 0 1.25rem; gap: 1rem; }
.zb-topbar .breadcrumbs { color: var(--ink-500); font-size: .85rem; }
.zb-topbar .breadcrumbs .sep { color: var(--ink-300); margin: 0 .5rem; }
.zb-topbar .breadcrumbs .current { color: var(--ink-900); font-weight: 600; }
.zb-topbar .user-pill { display: inline-flex; align-items: center; gap: .5rem; padding: .25rem .65rem; border-radius: 999px; background: var(--beige-50); color: var(--ink-700); font-size: .8rem; }

/* Layout container */
.zb-layout { display: flex; min-height: 100vh; }
.zb-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.zb-content { padding: 1.5rem 1.25rem; flex: 1; }

/* Flash messages */
.zb-flash-stack { position: fixed; bottom: 1rem; inset-inline-end: 1rem; display: flex; flex-direction: column; gap: .5rem; z-index: 1080; }
.zb-flash { background: white; border: 1px solid var(--line-100); box-shadow: 0 6px 24px rgba(20,30,25,.10); padding: .75rem 1rem; border-radius: 10px; min-width: 240px; font-size: .9rem; }
.zb-flash.success { border-left: 3px solid var(--green-600); }
.zb-flash.error   { border-left: 3px solid var(--coral-600); }

/* HTMX swap highlight */
@keyframes zb-flash-row { 0% { background: var(--green-100); } 100% { background: transparent; } }
.zb-flash-row { animation: zb-flash-row 1.5s ease-out; }

/* HTMX spinner overlay */
.zb-spinner-overlay { position: fixed; top: 0; inset-inline-start: 0; right: 0; height: 3px; background: var(--green-600); z-index: 9999; display: none; }
.htmx-request .zb-spinner-overlay { display: block; animation: zb-progress 1.2s linear infinite; }
@keyframes zb-progress { 0% { width: 0; opacity: .8; } 50% { width: 50%; opacity: 1; } 100% { width: 100%; opacity: 0; } }

/* Variant matrix table */
.variant-matrix { font-size: .85rem; }
.variant-matrix input.form-control { font-size: .85rem; padding: .25rem .5rem; height: 32px; }
.variant-matrix th { white-space: nowrap; }

/* Image gallery */
.image-tile { position: relative; aspect-ratio: 1; background: var(--beige-50); border: 1px solid var(--line-100); border-radius: 8px; overflow: hidden; }
.image-tile img { width: 100%; height: 100%; object-fit: cover; }
.image-tile .image-actions { position: absolute; inset-inline-end: .25rem; top: .25rem; display: none; gap: .15rem; }
.image-tile:hover .image-actions { display: flex; }

/* Status timeline (orders detail) */
.status-timeline { display: flex; flex-direction: column; gap: .35rem; padding-inline-start: 1.25rem; border-inline-start: 2px solid var(--line-100); }
.status-timeline .step { font-size: .85rem; color: var(--ink-700); position: relative; padding: .25rem 0; }
.status-timeline .step::before { content: ''; position: absolute; inset-inline-start: -1.6rem; top: .55rem; width: 10px; height: 10px; border-radius: 50%; background: var(--green-600); }

/* Tree view (categories) */
.cat-tree { list-style: none; padding-inline-start: 0; }
.cat-tree ul { list-style: none; padding-inline-start: 1.25rem; }
.cat-tree .cat-row { display: flex; align-items: center; gap: .35rem; padding: .35rem .5rem; border-radius: 6px; }
.cat-tree .cat-row:hover { background: var(--beige-50); }

/* Reports KPI strip */
.report-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .75rem; }

/* Modern admin pass: shell, filters, tables, and paging. */
body {
  background:
    linear-gradient(180deg, rgba(234, 244, 244, .54), rgba(253, 252, 250, 0) 220px),
    var(--off-white);
}

.card {
  border-color: var(--line-100);
  border-radius: 14px;
  box-shadow: 0 8px 22px rgba(26, 31, 28, .045);
}

.card-header:first-child {
  border-radius: 14px 14px 0 0;
}

.zb-table-card {
  overflow: hidden;
}

.zb-table-card .table-responsive {
  scrollbar-width: thin;
}

.zb-table-card tbody tr:last-child td {
  border-bottom: 0;
}

.zb-list-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .75rem;
  background: rgba(255, 253, 248, .86);
  border: 1px solid var(--line-100);
  border-radius: 14px;
  box-shadow: 0 8px 20px rgba(26, 31, 28, .04);
}

.zb-filter-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
}

.zb-filter-form .form-control,
.zb-filter-form .form-select {
  min-width: 9rem;
  width: auto;
}

.zb-filter-form input[name="q"] {
  min-width: 15rem;
}

.zb-pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  margin-top: 1rem;
  padding: .75rem;
  border: 1px solid var(--line-100);
  border-radius: 12px;
  background: rgba(255, 255, 255, .76);
}

.zb-pager .form-select {
  width: auto;
}

.zb-sidebar {
  background:
    linear-gradient(180deg, rgba(35, 55, 42, .99) 0%, rgba(44, 66, 51, .99) 45%, rgba(56, 79, 61, .99) 100%);
  position: sticky;
  top: 0;
  overflow-y: auto;
  backdrop-filter: blur(10px);
  border-inline-end: 1px solid rgba(16, 22, 18, .35);
  box-shadow:
    inset -1px 0 0 rgba(255, 255, 255, .05),
    20px 0 44px rgba(14, 20, 16, .18);
}

.zb-sidebar .nav-link {
  border-radius: 8px;
  padding: .52rem .75rem;
  color: rgba(255, 251, 244, .88);
}

.zb-sidebar .nav-link.active {
  font-weight: 700;
  color: var(--ink-900);
  background: rgba(255, 255, 255, .94);
  box-shadow:
    0 10px 18px rgba(20, 28, 22, .16),
    inset 0 0 0 1px rgba(255, 255, 255, .48);
}

.zb-topbar {
  height: 60px;
  background: rgba(255, 255, 255, .86);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(45, 53, 48, .1);
  box-shadow: 0 8px 24px rgba(26, 31, 28, .035);
}

.zb-content {
  max-width: 1440px;
  width: 100%;
  padding-bottom: 2rem;
}

.zb-main {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .62) 0%, rgba(250, 247, 241, .88) 100%);
}

.zb-content-shell {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding: 1rem;
  border-radius: 26px;
  background: rgba(255, 255, 255, .36);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .85);
}

.zb-page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1.35rem;
  border: 1px solid var(--line-100);
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(255,255,255,.98), rgba(238,247,242,.82)),
    var(--paper);
  box-shadow: 0 14px 34px rgba(26, 31, 28, .06);
}

.zb-page-copy {
  min-width: 0;
}

.zb-page-kicker,
.zb-topbar-kicker,
.zb-note-label,
.zb-mini-label,
.zb-info-label {
  display: inline-block;
  font-size: .73rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-400);
}

.zb-page-title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .75rem;
  margin-top: .4rem;
}

.zb-page-title {
  margin: 0;
  font-size: clamp(1.55rem, 2vw, 2.2rem);
  line-height: 1.08;
  font-weight: 700;
  color: var(--ink-900);
}

.zb-page-description {
  max-width: 58rem;
  margin-top: .55rem;
  color: var(--ink-500);
  line-height: 1.7;
}

.zb-page-stat {
  display: inline-flex;
  align-items: center;
  min-height: 2rem;
  padding: .35rem .8rem;
  border-radius: 999px;
  background: var(--green-100);
  color: var(--green-900);
  font-size: .82rem;
  font-weight: 700;
}

.zb-page-actions,
.zb-page-header-btns {
  display: flex;
  align-items: center;
  gap: .65rem;
  flex-wrap: wrap;
}

.zb-sidebar {
  width: 264px;
  padding: 1rem .9rem;
}

.zb-sidebar-intro {
  padding: .85rem .9rem;
  margin: 0 .15rem 1rem;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, .12), rgba(255, 255, 255, .05));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .08),
    0 10px 18px rgba(14, 20, 16, .12);
}

.zb-sidebar-intro strong {
  display: block;
  color: rgba(255, 255, 255, .96);
  margin-bottom: .25rem;
}

.zb-sidebar-intro span {
  display: block;
  color: rgba(255, 251, 244, .72);
  font-size: .8rem;
  line-height: 1.55;
}

.zb-topbar {
  justify-content: space-between;
  gap: 1rem;
  padding-inline: 1.4rem;
}

.zb-topbar-copy {
  min-width: 0;
}

.zb-topbar-tools {
  display: flex;
  align-items: center;
  gap: .65rem;
}

.zb-topbar .breadcrumbs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .35rem;
  margin-top: .15rem;
}

.zb-topbar .breadcrumbs a {
  color: var(--ink-500);
}

.zb-topbar .breadcrumbs .current {
  color: var(--ink-900);
}

.zb-topbar .user-pill {
  gap: .35rem;
  padding-inline: .8rem;
}

.user-pill-label {
  color: var(--ink-400);
  font-size: .72rem;
}

.zb-sidebar .brand-name,
.zb-sidebar .brand-name small,
.zb-sidebar .nav-section,
.zb-sidebar .locale-toggle,
.zb-sidebar .locale-toggle .btn {
  color: rgba(255, 251, 244, .82);
}

.zb-sidebar .nav-section {
  color: rgba(208, 223, 213, .58);
}

.zb-sidebar .nav-link:hover {
  color: rgba(255, 255, 255, .96);
  background: rgba(255, 255, 255, .08);
}

.zb-sidebar .brand-mark {
  background: rgba(255, 255, 255, .94);
  color: var(--green-900);
}

.zb-sidebar .brand-mark::after {
  background: #f4b13d;
}

.zb-sidebar .brand-logo {
  border: 1px solid rgba(255, 255, 255, .28);
}

.zb-section-card {
  border-radius: 18px;
}

.zb-card-header-stack {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .85rem;
}

.zb-card-header-stack p {
  max-width: 44rem;
}

.zb-toolbar-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.zb-chip-muted {
  display: inline-flex;
  align-items: center;
  min-height: 2rem;
  padding: .35rem .75rem;
  border-radius: 999px;
  background: var(--beige-50);
  color: var(--ink-700);
  border: 1px solid var(--line-100);
  font-size: .82rem;
  font-weight: 600;
}

.zb-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
}

.zb-note-card {
  border: 1px solid rgba(74, 124, 89, .12);
  background: linear-gradient(180deg, rgba(234,244,244,.92), rgba(255,255,255,.98));
}

.zb-focus-list {
  display: grid;
  gap: .85rem;
  margin-top: .75rem;
}

.zb-focus-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: .85rem;
  align-items: flex-start;
  padding: .8rem;
  border-radius: 14px;
  background: rgba(255,255,255,.76);
  border: 1px solid rgba(45, 53, 48, .06);
}

.zb-focus-value {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 3rem;
  height: 3rem;
  padding: 0 .8rem;
  border-radius: 999px;
  background: var(--ink-900);
  color: white;
  font-size: 1rem;
  font-weight: 700;
}

.zb-quick-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .75rem;
}

.zb-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
}

.zb-mini-stat {
  border-radius: 16px;
}

.zb-mini-value {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--ink-900);
}

.zb-detail-aside {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: sticky;
  top: 88px;
}

.zb-info-list {
  display: grid;
  gap: .8rem;
}

.zb-info-list strong {
  display: block;
  color: var(--ink-900);
}

.zb-summary-list {
  display: grid;
  gap: .65rem;
}

.zb-product-thumb {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  object-fit: cover;
  border: 1px solid var(--line-100);
  background: var(--beige-50);
}

.zb-product-thumb-empty {
  display: block;
}

.zb-image-caption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  margin-top: .4rem;
}

@media (max-width: 767.98px) {
  .zb-layout {
    display: block;
  }

  .zb-content {
    padding: 1rem;
  }

  .zb-page-head,
  .zb-topbar {
    height: auto;
    min-height: 56px;
    align-items: flex-start;
    padding-block: .75rem;
  }

  .zb-page-head,
  .zb-list-toolbar,
  .zb-pager,
  .zb-toolbar-title,
  .zb-card-header-stack,
  .zb-page-actions,
  .zb-page-header-btns,
  .zb-topbar-tools {
    align-items: stretch;
    flex-direction: column;
  }

  .zb-page-title-row {
    align-items: flex-start;
  }

  .zb-summary-grid,
  .zb-quick-grid {
    grid-template-columns: 1fr;
  }

  .zb-detail-aside {
    position: static;
  }

  .zb-filter-form .form-control,
  .zb-filter-form .form-select,
  .zb-filter-form input[name="q"] {
    width: 100%;
    min-width: 0;
  }

  .table .row-actions {
    opacity: 1;
  }
}
