/* ───────────────────────────────────────────────────────────
   The Auction House — RTL Arabic UI
   Palette inspired by the spec: ivory + gold + deep charcoal.
   ─────────────────────────────────────────────────────────── */
:root {
  --gold: #b08d49;
  --gold-dark: #8a6d34;
  --charcoal: #1c1c1c;
  --ink: #2b2b2b;
  --muted: #7a7a7a;
  --bg: #f6f4ef;
  --panel: #ffffff;
  --line: #e7e2d8;
  --ok: #2e7d54;
  --warn: #c08a2d;
  --danger: #b3402f;
  --radius: 10px;
  --shadow: 0 2px 14px rgba(0, 0, 0, 0.06);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Tajawal', system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  direction: rtl;
  line-height: 1.5;
}
.hidden { display: none !important; }

/* ---------- Buttons & fields ---------- */
.btn {
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 500;
  border: 1px solid transparent;
  /* Professional ERP look: near-square corners. */
  border-radius: 4px;
  padding: 7px 14px;
  cursor: pointer;
  transition: all .15s ease;
  /* Uniform across every screen: <a> and <button> render identically. */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  vertical-align: middle;
}
.btn-primary { background: var(--gold); color: #fff; }
.btn-primary:hover { background: var(--gold-dark); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { background: #f0ece2; }
.btn-block { width: 100%; }
/* Compact size used in toolbars — tighter height & padding. */
.btn-sm { padding: 5px 11px; font-size: 12.5px; border-radius: 4px; }

.field { margin-bottom: 18px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
input, select, textarea {
  width: 100%;
  font-family: inherit;
  font-size: 14px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gold); }
.error-msg { color: var(--danger); font-size: 13px; min-height: 18px; margin: 8px 0 0; }

/* ---------- Login ---------- */
.login-screen {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 30%, #fffdf8, var(--bg));
}
.login-card {
  width: 360px; background: var(--panel);
  padding: 36px 30px; border-radius: 16px; box-shadow: var(--shadow);
  border: 1px solid var(--line); text-align: center;
}
.brand-mark { font-size: 44px; color: var(--gold); }
.brand-mark-sm { font-size: 26px; color: var(--gold); }
.brand-title { letter-spacing: 3px; font-size: 20px; margin: 8px 0 2px; color: var(--charcoal); }
.brand-sub { color: var(--muted); font-size: 13px; margin: 0 0 24px; }
.login-card .field { text-align: right; }

/* ---------- App shell ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 248px; background: var(--charcoal); color: #ece7dc;
  display: flex; flex-direction: column; flex-shrink: 0;
}
.sidebar-brand { display: flex; gap: 10px; align-items: center; padding: 20px; border-bottom: 1px solid #333; }
.sidebar-brand strong { display: block; font-size: 15px; }
.sidebar-brand small { color: #a59b86; font-size: 12px; }
.nav-menu { flex: 1; padding: 12px 0; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 20px; color: #cfc8b9; cursor: pointer;
  font-size: 14px; border-right: 3px solid transparent;
}
.nav-item:hover { background: #262626; color: #fff; }
.nav-item.active { background: #262626; color: var(--gold); border-right-color: var(--gold); }
.nav-item .ic { width: 20px; text-align: center; }
.sidebar-footer { padding: 16px; border-top: 1px solid #333; }
.current-user { font-size: 13px; margin-bottom: 10px; }
.current-user .role { color: var(--gold); font-size: 12px; }

.content { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: 16px; justify-content: space-between;
  padding: 14px 24px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.back-btn { flex-shrink: 0; font-weight: 500; }
.search-box { flex: 1; max-width: 560px; }
.search-box input { background: #faf8f3; }
.topbar-title { font-weight: 700; color: var(--charcoal); }
.page { padding: 24px; overflow-y: auto; }

/* ---------- Generic page components ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.page-head h2 { margin: 0; font-size: 20px; color: var(--charcoal); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
        box-shadow: var(--shadow); padding: 22px 24px; margin-bottom: 20px; }
.card h3 { margin: 0 0 16px; font-size: 16px; color: var(--charcoal); }
/* Comfortable spacing between fields: clear vertical & horizontal separation. */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 15px 32px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; }
/* Each label:value line gets breathing room; labels read as muted, values stand out. */
.card .grid-2 > div, .card .grid-3 > div { line-height: 1.7; }
.card .grid-2 > div > strong, .card .grid-3 > div > strong { color: var(--muted); font-weight: 600; margin-inline-end: 8px; }

.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
        padding: 20px; box-shadow: var(--shadow); }
.clickable { cursor: pointer; }
.stat.clickable:hover { border-color: var(--gold); }
tr.clickable:hover { background: #faf7f0; }
.stat .label { color: var(--muted); font-size: 13px; line-height: 1.5; }
.stat .value { font-size: 26px; font-weight: 700; color: var(--charcoal); margin-top: 10px; }
.stat .value small { font-size: 14px; color: var(--muted); font-weight: 400; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: right; padding: 13px 14px; border-bottom: 1px solid var(--line); line-height: 1.55; }
th { color: var(--muted); font-weight: 500; background: #faf8f3; }
tbody tr:hover { background: #faf8f3; cursor: pointer; }

/* Square status pills (ERP/banking look) — slight 3px corners, colors & size unchanged. */
.badge { display: inline-block; padding: 3px 10px; border-radius: 3px; font-size: 12px; font-weight: 500; }
.badge-received { background: #eef2f7; color: #3b5673; }
.badge-listed { background: #fff3df; color: #9a6b14; }
.badge-sold { background: #e7f4ec; color: var(--ok); }
.badge-collected { background: #e3f0ff; color: #1f5fad; }
.badge-settled, .badge-paid_out { background: #efe7f7; color: #6b3fa0; }
.badge-delivered, .badge-closed, .badge-returned_to_owner { background: #eceae4; color: #555; }
.badge-unsold { background: #fff3df; color: #9a6b14; }
.badge-cancelled { background: #fbeae7; color: var(--danger); }

.muted { color: var(--muted); }
/* Commission/income figures — hidden for the operator role */
body.role-operator .fin-only { display: none !important; }
.row-actions { display: flex; gap: 8px; }
.amount { font-variant-numeric: tabular-nums; font-weight: 700; }
.amount-words { font-size: 13px; color: var(--gold-dark); }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--charcoal); color: #fff; padding: 12px 22px; border-radius: var(--radius);
  box-shadow: var(--shadow); z-index: 1000; font-size: 14px;
}
.toast.ok { background: var(--ok); }
.toast.err { background: var(--danger); }

.pay-row { display: grid; grid-template-columns: 130px 1fr 1fr 120px 40px; gap: 8px; margin-bottom: 8px; align-items: center; }
.pay-row input, .pay-row select { padding: 8px 10px; }

.sig-pad { border: 1px dashed var(--gold); border-radius: 8px; background: #fffdf8;
           touch-action: none; cursor: crosshair; max-width: 100%; margin-bottom: 10px; display: block; }

/* Unified deal document gallery */
.doc-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.doc-thumb { display: block; border: 1px solid var(--line); border-radius: 8px; overflow: hidden;
  background: #faf8f3; text-decoration: none; color: var(--ink); }
.doc-thumb img { width: 100%; height: 120px; object-fit: cover; display: block; }
.doc-thumb span { display: block; font-size: 11.5px; padding: 6px 8px; text-align: center; color: var(--muted);
  border-top: 1px solid var(--line); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-thumb:hover { border-color: var(--gold); }

.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.photo-thumb { position: relative; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #faf8f3; }
.photo-thumb img { width: 100%; height: 120px; object-fit: cover; display: block; }
.photo-tag { position: absolute; bottom: 0; right: 0; left: 0; background: rgba(28,28,28,.72); color: #fff;
             font-size: 12px; padding: 3px 6px; text-align: center; }
.photo-del { position: absolute; top: 6px; left: 6px; width: 24px; height: 24px; border-radius: 50%;
             border: none; background: rgba(179,64,47,.9); color: #fff; cursor: pointer; font-size: 16px; line-height: 1; }
.photo-del:hover { background: var(--danger); }

/* Filter bar + segmented control */
.filter-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.filter-bar select, .filter-bar input { width: auto; flex: 0 1 auto; }
.filter-bar #f-search { flex: 1; min-width: 200px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.seg-btn { background: #fff; border: none; padding: 9px 16px; cursor: pointer; font-family: inherit;
  font-size: 14px; color: var(--ink); border-left: 1px solid var(--line); }
.seg-btn:last-child { border-left: none; }
.seg-btn.active { background: var(--gold); color: #fff; }
.flbl { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.flbl input { padding: 7px 9px; }

/* Uploaded-image preview (cheque / transfer proof / ID) */
.file-preview { display: block; margin-top: 10px; max-width: 100%; max-height: 200px;
  border: 1px solid var(--line); border-radius: 8px; cursor: zoom-in; object-fit: contain; background: #faf8f3; }

/* Client smart-filter additions */
.strip5 { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 16px; }
.quick-bar { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.chip-btn { background: #fff; border: 1px solid var(--line); border-radius: 20px; padding: 7px 14px;
  font-family: inherit; font-size: 13px; cursor: pointer; color: var(--ink); }
.chip-btn:hover { background: #f0ece2; }
.chip-btn.active { background: var(--gold); color: #fff; border-color: var(--gold); }
.chip-clear { color: var(--danger); border-color: #f0d4ce; }
.mini-thumb { width: 42px; height: 42px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); display: block; }
/* Grouped search result sections */
.search-group h3 { display: flex; align-items: center; gap: 8px; }
.search-group h3 .count { background: var(--gold); color: #fff; border-radius: 20px; padding: 1px 11px; font-size: 13px; font-weight: 700; }
.search-group tbody tr { cursor: pointer; }
.search-group tbody tr:hover { background: #faf7ef; }
/* Automatic VIP tier badges */
.vip { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 3px; margin-right: 4px; vertical-align: middle; }
.vip-client { background: #fbf0d2; color: #9a7d14; border: 1px solid #e8d18a; }
/* Cheque status badges */
.badge.chq-received { background: #eef2f7; color: #3b5673; }
.badge.chq-deposited { background: #fff3df; color: #9a6b14; }
.badge.chq-cleared { background: #e7f4ec; color: var(--ok); }
.badge.chq-bounced { background: #fbeae7; color: var(--danger); }
.lnk { color: var(--gold); cursor: pointer; text-decoration: underline; }
/* Unified deal file — centered title + dedicated actions row */
.deal-header { text-align: center; margin: 6px 0 4px; }
.deal-header .deal-title { font-size: 15px; color: var(--muted); font-weight: 600; letter-spacing: 1px; }
.deal-header .deal-number { font-size: 28px; font-weight: 800; color: var(--gold); letter-spacing: 1px; margin-top: 2px; }
.deal-actions-bar { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px;
  padding: 9px 10px; margin: 8px 0 14px; background: #fff; border: 1px solid var(--line); border-radius: 6px; }
/* Movement-log timeline */
.timeline { display: flex; flex-direction: column; gap: 0; }
.timeline .tl-item { display: flex; gap: 10px; padding: 8px 0; border-right: 2px solid #eadfc3; padding-right: 14px; position: relative; }
.timeline .tl-item:last-child { border-right-color: transparent; }
.timeline .tl-dot { position: absolute; right: -11px; top: 6px; background: #fff; font-size: 15px; line-height: 1; }
.timeline .tl-body { font-size: 13px; }
.wtable { min-width: 1100px; font-size: 13px; }
.wtable th, .wtable td { padding: 8px 10px; white-space: nowrap; }

/* Autocomplete (seller lookup) */
.ac-list { position: absolute; top: 100%; right: 0; left: 0; z-index: 200; background: #fff;
  border: 1px solid var(--line); border-radius: 0 0 10px 10px; box-shadow: 0 8px 22px rgba(0,0,0,.12);
  max-height: 260px; overflow-y: auto; }
.ac-item { padding: 10px 14px; cursor: pointer; border-bottom: 1px solid #f2efe8; }
.ac-item:last-child { border-bottom: none; }
.ac-item:hover { background: #faf7f0; }
.ac-item strong { display: block; font-size: 14px; color: var(--charcoal); }
.ac-item small { color: var(--muted); font-size: 12px; }

/* Deal progress banner + stepper */
.deal-banner { padding: 12px 18px; border-radius: var(--radius); font-weight: 700; font-size: 15px; margin-bottom: 14px; }
.deal-banner.ok { background: #e7f4ec; color: #1f7a4d; border: 1px solid #bfe3cd; }
.deal-banner.warn { background: #fdf3e3; color: #9a6b14; border: 1px solid #f0dcae; }
.deal-banner.err { background: #fbeae7; color: #b3402f; border: 1px solid #f0cabf; }
.deal-banner b { font-weight: 800; }
.stepper { display: flex; gap: 6px; margin-bottom: 18px; flex-wrap: wrap; }
.step { flex: 1; min-width: 130px; display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 12px 8px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  position: relative; box-shadow: var(--shadow); }
.step .dot { width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: #eceae4; color: #999; font-weight: 700; font-size: 14px; }
.step .lbl { font-size: 12.5px; color: var(--muted); text-align: center; }
.step.done .dot { background: var(--ok); color: #fff; }
.step.done .lbl { color: var(--ink); }
.step.current { border-color: var(--gold); }
.step.current .dot { background: var(--gold); color: #fff; }
.step.current .lbl { color: var(--gold-dark); font-weight: 700; }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 1100;
  display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-card { background: var(--panel); border-radius: 12px; width: 560px; max-width: 100%;
  max-height: 90vh; overflow-y: auto; box-shadow: 0 10px 40px rgba(0,0,0,.3); }
.modal-head { display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 17px; color: var(--charcoal); }
.modal-x { background: none; border: none; font-size: 24px; cursor: pointer; color: var(--muted); line-height: 1; }
.modal-x:hover { color: var(--danger); }
.modal-body { padding: 20px; }

/* Alerts page */
.alert-chips { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 18px; }
.alert-chip { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 16px; font-size: 14px; box-shadow: var(--shadow); display: flex; align-items: center; gap: 8px; }
.alert-chip .n { font-size: 20px; font-weight: 700; }
.alert-chip.cat-red .n { color: #b3402f; }
.alert-chip.cat-orange .n { color: #c08a2d; }
.alert-chip.cat-yellow .n { color: #9a7d14; }
.alert-chip.cat-blue .n { color: #3b5673; }
.alert-chip.cat-gray .n { color: #6b6f76; }
.alert-group { padding: 0; overflow: hidden; }
.alert-group-head { display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px; font-weight: 700; border-right: 5px solid transparent; }
.alert-group-head small { font-weight: 400; color: var(--muted); font-size: 13px; }
.alert-group-head .count { background: rgba(0,0,0,.08); border-radius: 20px; padding: 1px 10px; font-size: 13px; margin-right: 4px; }
.alert-group-head.cat-red { background: #fbeae7; border-right-color: #b3402f; }
.alert-group-head.cat-orange { background: #fdf3e3; border-right-color: #c08a2d; }
.alert-group-head.cat-yellow { background: #fcf8e3; border-right-color: #9a7d14; }
.alert-group-head.cat-blue { background: #eef2f7; border-right-color: #3b5673; }
.alert-group-head.cat-gray { background: #f0f1f3; border-right-color: #6b6f76; }
.alert-group table { margin: 0; }
.alert-group th { background: #fff; }

.note-box {
  background: #fbf7ee; border-right: 4px solid var(--gold);
  padding: 12px 16px; border-radius: 8px; font-size: 13px; color: var(--ink); margin: 12px 0;
}
.divider { height: 1px; background: var(--line); margin: 18px 0; }

@media (max-width: 900px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .sidebar { width: 64px; }
  .sidebar-brand div, .nav-item span:not(.ic), .current-user { display: none; }
}
