/* ============================================================================
   Auction Messenger — "auctioneer's tally sheet"
   Calm admin surface: warm charcoal ink for structure + primary actions,
   one auction-red accent for the brand mark and destructive actions, and a
   monospace ledger face for figures (counts, fees, statuses) so they scan.
   ============================================================================ */
:root {
  --ink:        #1c1b22;   /* structure, headings, primary buttons */
  --ink-soft:   #46444f;   /* secondary text */
  --paper:      #f2f1ee;   /* page background — warm neutral, not cream */
  --surface:    #ffffff;   /* cards */
  --line:       #e6e3dc;   /* hairline borders (warm) */
  --line-soft:  #efedE8;
  --accent:     #b83227;   /* auction red — brand mark + destructive only */
  --accent-dark:#8f2319;
  --muted:      #6b6a73;

  --font-display: "Space Grotesk", "Inter", system-ui, sans-serif;
  --font-body:    "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono:    "Space Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  /* Motion — calm & quick: state feedback, never performance */
  --ease-out-quart: cubic-bezier(0.25, 1, 0.5, 1);
  --ease-out-expo:  cubic-bezier(0.16, 1, 0.3, 1);
  --t-fast: 130ms;   /* instant feedback: press, color, focus */
  --t-base: 200ms;   /* state changes: hover, reveal, badge */
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 0.9rem;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6 {
  font-family: var(--font-display);
  letter-spacing: -0.014em;
}

a { color: var(--accent-dark); text-underline-offset: 2px; }
a:hover { color: var(--accent); }

.text-muted { color: var(--muted) !important; }

/* Ledger figure helper — tabular monospace numerals */
.figure { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ── Navbar ── */
.app-navbar {
  background: var(--ink);
  padding-top: 0.6rem;
  padding-bottom: 0.6rem;
  box-shadow: 0 1px 0 rgba(0,0,0,.25);
}
.navbar-brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.08rem;
  letter-spacing: -0.01em;
  color: #fff !important;
}
.brand-mark {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.18);
}
.app-navbar .nav-link {
  color: rgba(255,255,255,.74) !important;
  font-weight: 500;
  font-size: 0.85rem;
  padding: 0.4rem 0.85rem;
  border-radius: 8px;
  transition: background .15s, color .15s;
}
.app-navbar .nav-link:hover  { color: #fff !important; background: rgba(255,255,255,.08); }
.app-navbar .nav-link.active { color: #fff !important; background: rgba(255,255,255,.13); }

/* ── Buttons (unified hierarchy) ──
   Charcoal solid = primary "do it"; hairline outline = secondary; red = delete. */
.btn {
  font-weight: 500;
  border-radius: 8px;
  transition: background-color var(--t-fast) ease,
              border-color var(--t-fast) ease,
              color var(--t-fast) ease,
              box-shadow var(--t-fast) ease,
              transform 90ms var(--ease-out-quart);
}
.btn:active:not(:disabled) { transform: translateY(1px) scale(0.985); }
.btn-sm { font-size: 0.8rem; border-radius: 7px; }

.btn-primary {
  --bs-btn-bg: var(--ink);
  --bs-btn-border-color: var(--ink);
  --bs-btn-hover-bg: #2c2a37;
  --bs-btn-hover-border-color: #2c2a37;
  --bs-btn-active-bg: #000;
  --bs-btn-active-border-color: #000;
  --bs-btn-disabled-bg: #a6a4ad;
  --bs-btn-disabled-border-color: #a6a4ad;
  --bs-btn-disabled-color: #fff;
  font-weight: 600;
}
.btn-outline-primary {
  --bs-btn-color: var(--ink);
  --bs-btn-border-color: var(--line);
  --bs-btn-bg: var(--surface);
  --bs-btn-hover-bg: var(--ink);
  --bs-btn-hover-border-color: var(--ink);
  --bs-btn-hover-color: #fff;
  --bs-btn-active-bg: var(--ink);
  --bs-btn-active-border-color: var(--ink);
}
.btn-outline-secondary {
  --bs-btn-color: var(--ink-soft);
  --bs-btn-border-color: var(--line);
  --bs-btn-bg: var(--surface);
  --bs-btn-hover-bg: var(--ink);
  --bs-btn-hover-border-color: var(--ink);
  --bs-btn-hover-color: #fff;
  --bs-btn-active-bg: var(--ink);
  --bs-btn-active-border-color: var(--ink);
}
.btn-danger {
  --bs-btn-bg: var(--accent);
  --bs-btn-border-color: var(--accent);
  --bs-btn-hover-bg: var(--accent-dark);
  --bs-btn-hover-border-color: var(--accent-dark);
  --bs-btn-active-bg: var(--accent-dark);
  --bs-btn-active-border-color: var(--accent-dark);
}
.btn-outline-danger {
  --bs-btn-color: var(--accent);
  --bs-btn-border-color: #e3b6b0;
  --bs-btn-hover-bg: var(--accent);
  --bs-btn-hover-border-color: var(--accent);
  --bs-btn-hover-color: #fff;
}
.btn-link { --bs-btn-color: var(--accent-dark); --bs-btn-hover-color: var(--accent); }

/* ── Forms ── */
.form-control, .form-select {
  border-color: var(--line);
  border-radius: 8px;
  font-size: 0.86rem;
  color: var(--ink);
  transition: border-color var(--t-fast) ease, box-shadow var(--t-fast) ease;
}
.form-control-sm, .form-select-sm { border-radius: 7px; }
.form-control:focus, .form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(184,50,39,.14);
}
.form-label { color: var(--ink-soft); }
.form-check-input:checked { background-color: var(--ink); border-color: var(--ink); }
.form-check-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(184,50,39,.14); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── Stat cards ── */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1.15rem 1.3rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: 0 1px 2px rgba(28,27,34,.04);
  transition: box-shadow .15s, transform .15s;
}
.stat-card:hover { box-shadow: 0 6px 18px rgba(28,27,34,.08); transform: translateY(-1px); }
.stat-card .stat-icon {
  width: 46px; height: 46px;
  border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.35rem;
  flex-shrink: 0;
}
.stat-card .stat-value {
  font-family: var(--font-mono);
  font-size: 1.7rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.stat-card .stat-label {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-top: 0.3rem;
}

/* ── Tables ── */
.table-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 1px 2px rgba(28,27,34,.04);
  overflow: hidden;
}
.table { font-variant-numeric: tabular-nums; }
.table-card .table { margin-bottom: 0; }
.table-card .table thead th {
  background: #faf9f6;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  font-weight: 600;
  border-bottom: 1px solid var(--line);
  padding: 0.7rem 1rem;
}
.table-card .table tbody td {
  padding: 0.8rem 1rem;
  vertical-align: middle;
  border-color: var(--line-soft);
  transition: background-color var(--t-fast) ease;
}
.table-card .table tbody tr:last-child td { border-bottom: none; }
.table-hover > tbody > tr:hover > * { --bs-table-bg-state: #faf7f2; }

/* ── Section header ── */
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.section-title { font-family: var(--font-display); font-size: 1rem; font-weight: 600; margin: 0; }

/* ── Tabs ── */
.nav-tabs { border-bottom: 1px solid var(--line); }
.nav-tabs .nav-link {
  color: var(--muted);
  font-weight: 500;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: 0.55rem 0.95rem;
  transition: color var(--t-fast) ease, border-color var(--t-base) var(--ease-out-quart);
}
.nav-tabs .nav-link:hover { color: var(--ink); border-bottom-color: var(--line); }
.nav-tabs .nav-link.active {
  color: var(--ink);
  background: transparent;
  border-bottom-color: var(--accent);
  font-weight: 600;
}

/* ── Status badges ── */
.badge-sent    { background: #e4f3ea; color: #1f6b3b; }
.badge-failed  { background: #fbe9e7; color: var(--accent-dark); }
.badge-pending { background: #ecebe6; color: #5b5a54; }
.badge-partial { background: #fdf2dc; color: #8a5a14; }

.status-badge {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.26rem 0.62rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* Count chip (e.g. customers tally) — set as a ledger figure */
.badge.bg-secondary {
  background: var(--ink) !important;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.7rem !important;
}

/* ── Progress bar row ── */
.progress { background: #e7e5df; border-radius: 999px; }
.progress-mini { height: 6px; border-radius: 999px; }
.progress-bar.bg-success { background: #3f9d5a !important; }

/* ── Compose page ── */
.customer-card {
  background: var(--surface);
  border-radius: 12px;
  border: 1px solid var(--line);
  margin-bottom: 1rem;
  overflow: hidden;
  transition: box-shadow .15s;
}
.customer-card:hover { box-shadow: 0 4px 14px rgba(28,27,34,.08); }
.customer-card .card-header-row {
  padding: 0.75rem 1rem;
  background: #faf9f6;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.customer-card .card-body-inner { padding: 1rem; }

.msg-box {
  background: #faf9f6;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
  white-space: pre-wrap;
  min-height: 60px;
}
.msg-box[contenteditable="true"] {
  outline: none;
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(184,50,39,.12);
}

/* ── Import page ── */
.drop-zone {
  border: 2px dashed var(--line);
  border-radius: 12px;
  padding: 3rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
}
.drop-zone.drag-over, .drop-zone:hover { border-color: var(--accent); background: #fbf3f2; }
.drop-zone i { font-size: 2.5rem; color: #adb5bd; }

/* ── Settings / panels ── */
.settings-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 1px 2px rgba(28,27,34,.04);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}
.settings-section h6 {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--line-soft);
}

/* ── Type pills ── */
.type-pill {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
}
.type-pickup   { background: #e0f2fe; color: #0369a1; }
.type-shipping { background: #f3e8ff; color: #7e22ce; }

/* Sent-row highlight: pickup = light blue, shipping = light purple.
   Transition lets the tint ease in smoothly if a row flips to sent client-side. */
.row-sent-pickup   > td { background: #e8f5fe !important; transition: background-color var(--t-base) var(--ease-out-quart); }
.row-sent-shipping > td { background: #f6eefd !important; transition: background-color var(--t-base) var(--ease-out-quart); }

/* Import panel disclosure chevron rotates with its collapse state */
[data-bs-toggle="collapse"] .bi-chevron-down {
  transition: transform var(--t-base) var(--ease-out-quart);
}
[data-bs-toggle="collapse"][aria-expanded="true"] .bi-chevron-down { transform: rotate(180deg); }

/* ── Empty state ── */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.empty-state i { font-size: 2.6rem; display: block; margin-bottom: 0.75rem; color: #c9c5bc; }

/* ── Action bar ── */
.action-bar {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.7rem 0.85rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  box-shadow: 0 1px 2px rgba(28,27,34,.04);
}

.btn-sm { font-size: 0.8rem; }

.auction-row-link { text-decoration: none; color: inherit; }
.auction-row-link:hover td { background: #faf7f2; }

/* ── Alerts (flash messages) ── */
.alert {
  border-radius: 12px;
  border: 1px solid var(--line);
  font-size: 0.88rem;
  animation: flash-in var(--t-base) var(--ease-out-quart) both;
}
@keyframes flash-in {
  from { opacity: 0; transform: translateY(-7px); }
  to   { opacity: 1; transform: none; }
}
.alert-success { background: #edf6ef; border-color: #cfe6d2; color: #235c2c; }
.alert-danger  { background: #fbece9; border-color: #f0cdc7; color: var(--accent-dark); }
.alert-info    { background: #eef3f8; border-color: #d3e0ee; color: #274b6d; }
.alert-warning { background: #fdf6e6; border-color: #ecdcb4; color: #8a5a14; }

/* ── Modals ── */
.modal-content { border: none; border-radius: 16px; }
.modal-title { font-family: var(--font-display); }

/* ── Reply status badges (notification only, inline in table) ── */
.reply-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.22rem 0.6rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  background: #e0f2fe;
  color: #0369a1;
  white-space: nowrap;
}
.reply-badge.reply-new { background: #fdf2dc; color: #8a5a14; }
.reply-badge .reply-time { font-weight: 500; opacity: 0.8; }

/* Pulsing dot for unread replies */
.new-dot {
  display: inline-block;
  width: 6px; height: 6px;
  background: var(--accent);
  border-radius: 50%;
  animation: pulse-dot 1.4s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: .5; transform: scale(.7); }
}

/* Send feedback: a status badge flipping to "Sent" gets one confident pulse.
   Applied via JS (updateBadge) so it fires on the change, not on page load. */
@keyframes badge-pop {
  0%   { transform: scale(1); }
  45%  { transform: scale(1.12); }
  100% { transform: scale(1); }
}
.badge-pop { animation: badge-pop 320ms var(--ease-out-quart); }

/* Status/row feedback: follow-up flag and reply confirmations ease in when
   toggled client-side (class added by JS, not present on initial render). */
@keyframes chip-in {
  from { opacity: 0; transform: scale(0.85); }
  to   { opacity: 1; transform: none; }
}
.chip-in { animation: chip-in var(--t-base) var(--ease-out-expo); }

@keyframes cell-ack {
  0%   { background: rgba(63,157,90,.16); }
  100% { background: transparent; }
}
.cell-ack { animation: cell-ack 600ms var(--ease-out-quart); border-radius: 8px; }

/* ── Motion preference ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
