/* Chasb Ahvaz admin panel — Persian RTL, mobile first, no external assets. */
:root {
  --bg: #f6f1ea;
  --surface: #ffffff;
  --surface-2: #fbf7f1;
  --text: #2f2320;
  --muted: #7a6a62;
  --line: #e8dccd;
  --brand: #8f1837;
  --brand-dark: #6b1029;
  --brand-soft: #f8e9ee;
  --accent: #c45c2a;
  --ok: #16803c;
  --ok-soft: #e7f5ec;
  --warn: #a15c00;
  --warn-soft: #fff3df;
  --bad: #b42318;
  --bad-soft: #fdecea;
  --info: #1f5f99;
  --info-soft: #e8f1fa;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(47, 35, 32, .06), 0 4px 14px rgba(47, 35, 32, .05);
  --font: Vazirmatn, "Segoe UI", Tahoma, system-ui, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.7 var(--font); }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.4; margin: 0 0 .5em; }
h1 { font-size: 1.35rem; } h2 { font-size: 1.1rem; } h3 { font-size: 1rem; }
small, .muted { color: var(--muted); }
img { max-width: 100%; }
.num, .ltr { direction: ltr; unicode-bidi: isolate; }

/* layout */
.shell { display: grid; grid-template-columns: 1fr; min-height: 100vh; }
.sidebar { position: fixed; inset: 0 0 0 auto; width: 270px; background: #2a1d1b; color: #f3e9e1;
  transform: translateX(100%); transition: transform .2s; z-index: 30; overflow-y: auto; }
.sidebar.open { transform: none; }
.sidebar .brand { padding: 18px 18px 10px; font-weight: 800; font-size: 1.05rem; }
.sidebar .brand small { display: block; color: #bfa99c; font-weight: 400; font-size: .75rem; }
.sidebar nav a { display: flex; align-items: center; gap: 10px; padding: 11px 18px; color: #f3e9e1;
  border-inline-start: 3px solid transparent; }
.sidebar nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; }
.sidebar nav a.active { background: rgba(255,255,255,.1); border-inline-start-color: var(--accent); font-weight: 700; }
.sidebar .me { padding: 14px 18px; border-top: 1px solid rgba(255,255,255,.1); font-size: .85rem; color: #d9c8bd; }
.sidebar .me form { display: inline; }
.sidebar .me button { background: none; border: 0; color: #ffb8a0; cursor: pointer; font: inherit; padding: 0; }
.backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 25; }
.backdrop.show { display: block; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar .title { font-weight: 800; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu-btn { border: 1px solid var(--line); background: var(--surface-2); border-radius: 8px; width: 42px; height: 42px;
  font-size: 20px; cursor: pointer; }
main.content { padding: 14px; max-width: 1280px; width: 100%; margin: 0 auto; }
@media (min-width: 1000px) {
  .shell { grid-template-columns: 250px 1fr; }
  .sidebar { position: sticky; top: 0; height: 100vh; transform: none; width: 250px; }
  .menu-btn, .backdrop { display: none !important; }
  main.content { padding: 22px 26px; }
}

/* cards & grid */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; margin-bottom: 14px; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.card-head { display: flex; align-items: center; gap: 10px; justify-content: space-between; flex-wrap: wrap; margin-bottom: 10px; }
.grid { display: grid; gap: 14px; }
.grid.two { grid-template-columns: 1fr; }
.grid.three, .grid.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 760px) { .grid.two { grid-template-columns: 1fr 1fr; } .grid.three { grid-template-columns: repeat(3, 1fr); }
  .grid.four { grid-template-columns: repeat(4, 1fr); } }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.stat b { display: block; font-size: 1.35rem; color: var(--brand); }
.stat span { color: var(--muted); font-size: .85rem; }
.stat.link:hover { border-color: var(--brand); text-decoration: none; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px; padding: 8px 16px;
  border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font: 600 .95rem var(--font);
  cursor: pointer; white-space: nowrap; }
.btn:hover { text-decoration: none; border-color: var(--brand); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.danger { color: var(--bad); border-color: #f0c4be; }
.btn.danger.solid { background: var(--bad); color: #fff; border-color: var(--bad); }
.btn.ok { background: var(--ok); color: #fff; border-color: var(--ok); }
.btn.small { min-height: 34px; padding: 4px 10px; font-size: .85rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* forms */
label { font-weight: 600; font-size: .9rem; }
input[type=text], input[type=password], input[type=number], input[type=search], input:not([type]), select, textarea,
input[type=email], input[type=url], input[type=file] {
  width: 100%; min-height: 44px; padding: 8px 12px; border: 1px solid #dccbb7; border-radius: 8px; background: #fff;
  color: var(--text); font: 15px var(--font); }
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(143, 24, 55, .25); border-color: var(--brand); }
input.money, input[inputmode=numeric], input[inputmode=decimal] { direction: ltr; text-align: right; }
.field { margin-bottom: 12px; }
.field .help { font-size: .8rem; color: var(--muted); margin-top: 2px; }
.field .errors { color: var(--bad); font-size: .85rem; margin: 2px 0 0; padding: 0; list-style: none; }
.field.check { display: flex; align-items: center; gap: 8px; }
.field.check input { width: 20px; height: 20px; min-height: 0; }
.form-grid { display: grid; grid-template-columns: 1fr; gap: 0 14px; }
@media (min-width: 760px) { .form-grid { grid-template-columns: 1fr 1fr; } .form-grid .wide { grid-column: 1 / -1; } }
.checklist ul, ul.checklist { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; grid-template-columns: 1fr; }
@media (min-width: 760px) { .checklist ul, ul.checklist { grid-template-columns: 1fr 1fr; } }
.checklist label { font-weight: 500; display: flex; gap: 8px; align-items: center; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.filters > * { flex: 1 1 150px; }
.filters .btn { flex: 0 0 auto; }

/* tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.list { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.list th { text-align: right; font-weight: 700; color: var(--muted); font-size: .8rem; padding: 8px; border-bottom: 2px solid var(--line);
  white-space: nowrap; }
table.list td { padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list tr:hover td { background: var(--surface-2); }
table.list .thumb { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; background: var(--surface-2); display: block; }
table.list td.money, table.list th.money { text-align: left; white-space: nowrap; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }

/* badges */
.badge { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: .78rem; font-weight: 700; white-space: nowrap;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.badge.awaiting_payment, .badge.pending_review, .badge.warn, .badge.draft { background: var(--warn-soft); color: var(--warn); border-color: #f3d9ae; }
.badge.preparing, .badge.info, .badge.partial { background: var(--info-soft); color: var(--info); border-color: #c9ddf0; }
.badge.ready { background: #f2eafb; color: #5b2a91; border-color: #dccbf0; }
.badge.shipped, .badge.completed, .badge.ok, .badge.active, .badge.paid, .badge.confirmed { background: var(--ok-soft); color: var(--ok); border-color: #bfe3cb; }
.badge.cancelled, .badge.returned, .badge.bad, .badge.rejected, .badge.refunded, .badge.unpaid { background: var(--bad-soft); color: var(--bad); border-color: #f3c6c0; }
.badge.inactive, .badge.archived { background: #eee; color: #666; }

/* messages */
.messages { list-style: none; padding: 0; margin: 0 0 14px; }
.messages li { padding: 10px 14px; border-radius: 8px; margin-bottom: 8px; border: 1px solid; }
.messages .success { background: var(--ok-soft); border-color: #bfe3cb; color: #0f5a2a; }
.messages .error { background: var(--bad-soft); border-color: #f3c6c0; color: #8a1c12; }
.messages .warning { background: var(--warn-soft); border-color: #f3d9ae; color: #7a4600; }
.messages .info { background: var(--info-soft); border-color: #c9ddf0; color: #18456f; }

/* tabs / pills */
.pills { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.pills a { padding: 6px 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); color: var(--text); font-size: .9rem; }
.pills a.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.pills a:hover { text-decoration: none; border-color: var(--brand); }

/* order form */
.item-row { display: grid; grid-template-columns: 1fr 90px 130px 40px; gap: 8px; align-items: center; padding: 8px 0;
  border-bottom: 1px dashed var(--line); }
.item-row .name small { display: block; }
.item-row .line-total { grid-column: 1 / -1; font-size: .85rem; color: var(--muted); }
@media (max-width: 560px) { .item-row { grid-template-columns: 1fr 80px 110px 36px; } }
.picker { position: relative; }
.picker-results { position: absolute; inset-inline: 0; top: 100%; z-index: 10; background: #fff; border: 1px solid var(--line);
  border-radius: 8px; box-shadow: var(--shadow); max-height: 340px; overflow-y: auto; display: none; }
.picker-results.show { display: block; }
.picker-results button { display: block; width: 100%; text-align: right; padding: 9px 12px; border: 0; border-bottom: 1px solid var(--line);
  background: #fff; cursor: pointer; font: 14px var(--font); }
.picker-results button:hover, .picker-results button:focus { background: var(--brand-soft); }
.picker-results small { color: var(--muted); }
.total-box { font-size: 1.15rem; font-weight: 800; color: var(--brand); }
textarea.preview { min-height: 280px; font-size: .9rem; background: var(--surface-2); }

/* product images */
.images { display: flex; flex-wrap: wrap; gap: 10px; }
.images figure { margin: 0; width: 110px; text-align: center; }
.images img { width: 110px; height: 110px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.images figure.cover img { outline: 3px solid var(--accent); }
.images form { display: inline; }

/* misc */
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 4px 12px; font-size: .95rem; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; overflow-wrap: anywhere; }
.timeline { list-style: none; padding: 0; margin: 0; font-size: .88rem; }
.timeline li { padding: 6px 0; border-bottom: 1px dashed var(--line); }
.bar { height: 10px; background: var(--brand); border-radius: 4px; min-width: 2px; }
.bars td { padding: 4px 8px; }
.pagination { display: flex; gap: 6px; justify-content: center; align-items: center; margin-top: 12px; flex-wrap: wrap; }
.pagination a, .pagination span { padding: 6px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
details > summary { cursor: pointer; font-weight: 700; padding: 6px 0; }
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; }
.login-card h1 { text-align: center; color: var(--brand); }
.inline-form { display: inline-flex; gap: 6px; align-items: center; }
.inline-form input { width: 120px; min-height: 34px; padding: 4px 8px; }
.sticky-save { position: sticky; bottom: 0; background: rgba(246, 241, 234, .96); padding: 10px 0; border-top: 1px solid var(--line);
  display: flex; gap: 8px; z-index: 5; }
.hide-sm { display: none; }
@media (min-width: 760px) { .hide-sm { display: table-cell; } }
@media print { .sidebar, .topbar, .no-print { display: none !important; } }
