/* ============================================================
   chat-usage.css — the chat's «مصرف و اعتبار» surfaces (assets/js/chat/chat-usage.js; docs/PRICING_PLAN.md §9, §9-ب, §9-پ).
   Shell, not an extension: every family. Colours are the chat's own tokens (--nbgc-*, chat-canvas.css), so both themes
   come for free; on /account.php the page's tokens stand in (pricing.css maps them). Every pane declares its own
   direction (the chat body computes ltr). No scrim anywhere: the card floats, the page stays pressable.
   ============================================================ */

/* ---------- the card: small, centred, non-modal ---------- */
.nbg-uc {
  position: fixed;
  z-index: 12500;                      /* above the live panel (12000), so the wall can speak over a call */
  inset-inline: 0;
  top: 50%;
  margin-inline: auto;
  transform: translateY(-50%);
  box-sizing: border-box;
  width: min(380px, calc(100vw - 32px));
  max-height: calc(100dvh - 96px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 22px 20px 18px;
  border-radius: 20px;
  direction: rtl;
  text-align: start;
  font-family: var(--nbgc-font, inherit);
  background: var(--nbgc-sheet-face, var(--bg-secondary, #0f172a));
  color: var(--nbgc-ink, #e8eef6);
  border: 1px solid var(--nbgc-hairline-strong, rgba(148, 168, 200, 0.26));
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.46), 0 2px 10px rgba(0, 0, 0, 0.22);
  animation: nbg-uc-in 0.18s ease-out;
}
.nbg-uc--wide { width: min(460px, calc(100vw - 32px)); }
html[data-theme="light"] .nbg-uc { box-shadow: 0 22px 56px rgba(15, 23, 42, 0.18), 0 2px 8px rgba(15, 23, 42, 0.08); }
@keyframes nbg-uc-in {
  from { opacity: 0; transform: translateY(calc(-50% + 8px)) scale(0.985); }
  to { opacity: 1; transform: translateY(-50%) scale(1); }
}
@media (prefers-reduced-motion: reduce) { .nbg-uc { animation: none; } }
.nbg-uc.is-busy { cursor: progress; }

.nbg-uc-x {
  position: absolute;
  top: 6px;
  inset-inline-end: 6px;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--nbgc-ink-soft, #94a3b6);
  cursor: pointer;
}
.nbg-uc-x svg { width: 18px; height: 18px; }
.nbg-uc-x:hover, .nbg-uc-x:focus-visible { background: var(--nbgc-surface-2, rgba(148, 168, 200, 0.11)); color: var(--nbgc-ink, #e8eef6); }

.nbg-uc-kicker {
  margin: 0 0 4px;
  padding-inline-end: 40px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--nbgc-accent-ink, #6ee7b7);
}
.nbg-uc-title {
  margin: 0 0 8px;
  padding-inline-end: 40px;
  font-size: 18px;
  font-weight: 800;
  line-height: 1.55;
  color: var(--nbgc-ink-strong, var(--nbgc-ink, #fff));
  text-wrap: balance;
}
.nbg-uc-lead {
  margin: 0 0 14px;
  font-size: 14.5px;
  line-height: 1.95;
  color: var(--nbgc-ink-soft, #94a3b6);
}
.nbg-uc-body { margin: 0 0 14px; }
.nbg-uc-body:empty { display: none; }
.nbg-uc-balance {
  margin: 0;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 13.5px;
  line-height: 1.8;
  background: var(--nbgc-surface, rgba(148, 168, 200, 0.07));
  color: var(--nbgc-ink, #e8eef6);
}
.nbg-uc-balance b { font-weight: 800; }
.nbg-uc-soft { color: var(--nbgc-ink-soft, #94a3b6); font-weight: 500; }

.nbg-uc-msg {
  margin: 0 0 12px;
  font-size: 13.5px;
  line-height: 1.8;
  color: var(--nbgc-ink, #e8eef6);
}
.nbg-uc-msg.is-bad { color: #fca5a5; }
html[data-theme="light"] .nbg-uc-msg.is-bad { color: #b3261e; }

/* ---------- buttons: one primary, ≥ 48px, labels never truncated ---------- */
.nbg-uc-actions { display: grid; gap: 8px; }
.nbg-uc-btn {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  min-height: 48px;
  width: 100%;
  padding: 9px 14px;
  border-radius: 13px;
  border: 1px solid transparent;
  font: inherit;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.5;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.14s ease, border-color 0.14s ease, transform 0.08s ease;
}
.nbg-uc-btn:active { transform: scale(0.99); }
.nbg-uc-btn[disabled] { cursor: progress; }
.nbg-uc-btn-sub { font-size: 12.5px; font-weight: 600; }
.nbg-uc-btn--primary {
  background: var(--nbgc-accent, #34d399);
  color: var(--nbgc-ink-on-accent, #000);
}
.nbg-uc-btn--primary:hover, .nbg-uc-btn--primary:focus-visible { filter: brightness(1.06); }
.nbg-uc-btn--secondary {
  background: transparent;
  color: var(--nbgc-ink, #e8eef6);
  border-color: var(--nbgc-hairline-strong, rgba(148, 168, 200, 0.26));
}
.nbg-uc-btn--secondary .nbg-uc-btn-sub, .nbg-uc-btn--quiet .nbg-uc-btn-sub { color: var(--nbgc-ink-soft, #94a3b6); }
.nbg-uc-btn--secondary:hover, .nbg-uc-btn--secondary:focus-visible { background: var(--nbgc-surface-2, rgba(148, 168, 200, 0.11)); }
.nbg-uc-btn--quiet {
  background: transparent;
  color: var(--nbgc-ink-soft, #94a3b6);
  font-weight: 700;
}
.nbg-uc-btn--quiet:hover, .nbg-uc-btn--quiet:focus-visible { color: var(--nbgc-ink, #e8eef6); background: var(--nbgc-surface, rgba(148, 168, 200, 0.07)); }
.nbg-uc.is-busy .nbg-uc-btn { opacity: 0.72; }

.nbg-uc-note {
  margin: 12px 0 0;
  font-size: 12.5px;
  line-height: 1.85;
  color: var(--nbgc-ink-soft, #94a3b6);
}
.nbg-uc-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 2px 6px;
  margin: 10px 0 0;
  font-size: 13px;
}
.nbg-uc-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 6px;
  border: 0;
  background: none;
  font: inherit;
  font-weight: 700;
  color: var(--nbgc-accent-ink, #6ee7b7);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.nbg-uc-dot { color: var(--nbgc-ink-soft, #94a3b6); }

/* ---------- «خلاصهٔ خرید» lines ---------- */
.nbg-uc-lines { margin: 0; display: grid; gap: 6px; }
.nbg-uc-lines > div { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; line-height: 1.8; }
.nbg-uc-lines dt { color: var(--nbgc-ink-soft, #94a3b6); }
.nbg-uc-lines dd { margin: 0; font-weight: 700; color: var(--nbgc-ink, #e8eef6); }
.nbg-uc-lines .is-total { padding-top: 8px; border-top: 1px solid var(--nbgc-hairline, rgba(148, 168, 200, 0.16)); }
.nbg-uc-lines .is-total dd { font-size: 17px; font-weight: 800; }
.nbg-uc-gift { margin: 10px 0 0; font-size: 13px; line-height: 1.8; font-weight: 700; color: var(--nbgc-accent-ink, #6ee7b7); }

/* ---------- top-up amounts ---------- */
.nbg-uc-amounts { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.nbg-uc-amount {
  min-height: 48px;
  padding: 8px;
  border-radius: 12px;
  border: 1px solid var(--nbgc-hairline-strong, rgba(148, 168, 200, 0.26));
  background: var(--nbgc-surface, rgba(148, 168, 200, 0.07));
  color: var(--nbgc-ink, #e8eef6);
  font: inherit;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}
.nbg-uc-amount:hover, .nbg-uc-amount:focus-visible { border-color: var(--nbgc-accent, #34d399); }

/* ---------- the Word choice: two options side by side, the footer preview ---------- */
.nbg-uc-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 0 0 12px; }
@media (max-width: 400px) { .nbg-uc-pair { grid-template-columns: 1fr; } }
.nbg-uc-opt {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--nbgc-hairline-strong, rgba(148, 168, 200, 0.26));
}
.nbg-uc-opt.is-pick { border-color: var(--nbgc-accent-edge, rgba(52, 211, 153, 0.28)); background: var(--nbgc-accent-wash, rgba(52, 211, 153, 0.1)); }
.nbg-uc-opt-title { margin: 0; font-size: 14.5px; font-weight: 800; color: var(--nbgc-ink, #e8eef6); }
.nbg-uc-opt-sub { margin: 0 0 6px; flex: 1; font-size: 12.5px; line-height: 1.8; color: var(--nbgc-ink-soft, #94a3b6); }
.nbg-uc-opt .nbg-uc-btn { font-size: 14px; }

/* the page bottom as it will print: a real sheet is white in either theme */
.nbg-uc-paper {
  position: relative;
  display: grid;
  gap: 8px;
  margin: 0 0 12px;
  padding: 12px 14px 10px;
  border-radius: 10px;
  background: #ffffff;
  color: #1f2937;
  border: 1px solid rgba(15, 23, 42, 0.14);
}
.nbg-uc-paper-lines {
  height: 26px;
  background: repeating-linear-gradient(to bottom, #e5e7eb 0 3px, transparent 3px 9px);
  border-radius: 2px;
}
.nbg-uc-paper-foot {
  justify-self: center;
  font-size: 11.5px;
  color: #4b5563;                     /* 7.6:1 on white */
  border-top: 1px dashed #d1d5db;
  padding-top: 6px;
  width: 100%;
  text-align: center;
}
.nbg-uc-paper-tag {
  justify-self: center;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 800;
  color: #065f46;                     /* 7.9:1 on #ecfdf5 */
  background: #ecfdf5;
}

/* ---------- the fading note ---------- */
.nbg-ut {
  position: fixed;
  z-index: 12400;
  inset-inline: 0;
  bottom: calc(118px + env(safe-area-inset-bottom, 0px));
  margin-inline: auto;
  box-sizing: border-box;
  width: max-content;
  max-width: calc(100vw - 32px);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 8px 8px 14px;
  padding-inline-start: 16px;
  border-radius: 14px;
  direction: rtl;
  font-family: var(--nbgc-font, inherit);
  font-size: 13.5px;
  line-height: 1.8;
  background: var(--nbgc-sheet-face, var(--bg-secondary, #0f172a));
  color: var(--nbgc-ink, #e8eef6);
  border: 1px solid var(--nbgc-hairline-strong, rgba(148, 168, 200, 0.26));
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.35);
  animation: nbg-uc-in 0.18s ease-out;
}
.nbg-ut-btn {
  flex: none;
  min-height: 40px;
  padding: 0 12px;
  border-radius: 10px;
  border: 0;
  font: inherit;
  font-weight: 800;
  background: var(--nbgc-accent, #34d399);
  color: var(--nbgc-ink-on-accent, #000);
  cursor: pointer;
}

/* ---------- the faint credit line under a message or a file (chrome, never history) ---------- */
.nbg-credit-line {
  margin: 4px 0 0;
  padding-inline: 4px;
  direction: rtl;
  font-size: 12px;
  line-height: 1.7;
  color: var(--nbgc-ink-soft, #94a3b6);
}

/* ---------- the counter in the last 20%: it takes the fine print's place ---------- */
body.nbg-usage-counter-on .chat-input .composer-ai-disclaimer,
body.nbg-usage-counter-on .composer-ai-disclaimer { display: none !important; }
.nbg-usage-counter {
  display: flex;
  align-items: center;
  justify-content: center;
  width: max-content;
  max-width: 100%;
  min-height: 32px;
  margin: 2px auto 0;
  padding: 0 12px;
  box-sizing: border-box;
  direction: rtl;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 700;
  line-height: 1.6;
  text-decoration: none;
  color: var(--nbgc-accent-ink, #6ee7b7);
  background: var(--nbgc-accent-wash, rgba(52, 211, 153, 0.1));
}
.nbg-usage-counter[hidden] { display: none; }
.nbg-usage-counter:hover, .nbg-usage-counter:focus-visible { text-decoration: underline; text-underline-offset: 3px; }

/* ---------- the gear menu row (phone) ---------- */
#moreSheet .nbg-usage-menu-row { text-decoration: none; color: inherit; }
#moreSheet .nbg-usage-menu-row.has-mini { flex-direction: column; align-items: stretch; flex-shrink: 0; gap: 10px; padding-block: 12px; height: auto; }
#moreSheet .nbg-usage-menu-top { display: flex; align-items: center; gap: 10px; }
#moreSheet .nbg-usage-menu-mini:empty { display: none; }

/* ---------- the money rule of the usage pages (session 5): the Persian thousands separator «٬» sits on the
   baseline. The platform face draws U+066C high, where it reads as an apostrophe («۴۴‘۰۰۰»). An INLINE span moved
   with position:relative keeps the character, its bidi class and the line box as they are. ---------- */
.nbg-sep { position: relative; top: 0.24em; margin-inline: 0.08em; }

/* ---------- the small summary (account card, gear menu): three «مانده» bars, the balance, «جزئیات» ---------- */
.nbg-mini { direction: rtl; text-align: start; }
.nbg-mini-h { margin: 0 0 8px !important; font-size: 12.5px !important; font-weight: 800; color: var(--nbgc-ink-soft, var(--text-secondary, #555)); }
.nbg-mini.is-menu { display: grid; gap: 8px; }
/* one grid for all rows (rows are display:contents), so the bars start and end on the same line */
.nbg-mini-rows {
  display: grid;
  grid-template-columns: auto minmax(48px, 1fr) auto;
  align-items: center;
  gap: 9px 12px;
  font-size: 13px;
  line-height: 1.6;
}
.nbg-mini-row { display: contents; }
.nbg-mini-l { font-weight: 700; color: var(--nbgc-ink, var(--text, #111)); white-space: nowrap; }
.nbg-mini-v { font-weight: 800; color: var(--nbgc-ink, var(--text, #111)); white-space: nowrap; text-align: end; }
.nbg-mini-row.is-out .nbg-mini-v { color: #fca5a5; }                       /* the chat's dark canvas */
html[data-theme="light"] .nbg-mini-row.is-out .nbg-mini-v { color: #b91c1c; }    /* 6.5:1 on white */
.nbg-mini-bar { position: relative; display: block; height: 6px; border-radius: 999px; overflow: hidden; background: rgba(148, 163, 184, 0.28); }
.nbg-mini-bar > i { position: absolute; inset-block: 0; inset-inline-start: 0; border-radius: inherit; background: var(--nbgc-accent, #10b981); }
.nbg-mini-row.is-low .nbg-mini-bar > i { background: #f59e0b; }
.nbg-mini-row.is-out .nbg-mini-bar > i { background: #ef4444; }
.nbg-mini-bar.is-free { background: repeating-linear-gradient(90deg, rgba(148, 163, 184, 0.35) 0 6px, transparent 6px 10px); }
.nbg-mini-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; }
.nbg-mini.is-menu .nbg-mini-foot { margin-top: 2px; }
.nbg-mini-bal { font-size: 13px; color: var(--nbgc-ink-soft, var(--text-secondary, #555)); }
.nbg-mini-bal b { color: var(--nbgc-ink, var(--text, #111)); font-weight: 800; }
.nbg-mini-go {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 44px;
  padding: 0 14px;
  margin-inline-start: auto;
  border-radius: var(--nbgc-r-075, 10px);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
  color: var(--nbgc-accent-ink, #047857);
  border: 1px solid var(--border, rgba(0, 0, 0, 0.18));
}
.nbg-mini-go:focus-visible { outline: 2px solid var(--nbgc-accent-ink, #047857); outline-offset: 2px; }

/* ---------- the exam sheet: the «پیش‌نمایش» mark until it is bought ---------- */
.message.nbg-sheet-preview .message-bubble { position: relative; overflow: hidden; }
.message.nbg-sheet-preview .message-bubble::after {
  content: "پیش‌نمایش";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  font-size: clamp(42px, 12vw, 88px);
  font-weight: 900;
  letter-spacing: 0.04em;
  color: var(--nbgc-ink, #e8eef6);
  opacity: 0.07;
  transform: rotate(-24deg);
}
.nbg-sheet-plus-note {
  flex-basis: 100%;
  margin: 2px 0 0;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--nbgc-accent-ink, #6ee7b7);
}

/* ---------- the live class: «X دقیقه مانده» in the panel's corner, always ---------- */
#liveCallOverlay .live-call-stage { position: relative; }
#liveCallOverlay .nbg-live-left {
  position: absolute;
  z-index: 6;
  top: 10px;
  inset-inline-start: 12px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  direction: rtl;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.6;
  color: #e8eef6;
  background: rgba(15, 23, 42, 0.72);
  border: 1px solid rgba(148, 168, 200, 0.28);
  backdrop-filter: blur(6px);
}
#liveCallOverlay .nbg-live-left[hidden] { display: none; }
#liveCallOverlay .live-call-panel[data-live-theme="light"] .nbg-live-left {
  color: #14181d;
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(15, 23, 42, 0.14);
}
#liveCallOverlay .nbg-live-left.is-warn { color: #1c1300; background: #fbbf24; border-color: #f59e0b; }
#liveCallOverlay .live-call-panel[data-live-theme="light"] .nbg-live-left.is-warn { color: #1c1300; background: #fbbf24; }
#liveCallOverlay .nbg-live-left.is-pulse { animation: nbg-live-pulse 0.8s ease-in-out 3; }
@keyframes nbg-live-pulse { 50% { transform: scale(1.06); } }
@media (prefers-reduced-motion: reduce) { #liveCallOverlay .nbg-live-left.is-pulse { animation: none; } }
#liveCallOverlay .nbg-live-left-btn {
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  border: 0;
  font: inherit;
  font-size: 12.5px;
  font-weight: 800;
  background: #1c1300;
  color: #fbbf24;
  cursor: pointer;
}

/* focus: the card itself is focused on open (no outline); controls show a clear ring for keyboards only */
.nbg-uc:focus { outline: none; }
.nbg-uc .nbg-uc-btn:focus-visible, .nbg-uc .nbg-uc-link:focus-visible, .nbg-uc .nbg-uc-amount:focus-visible, .nbg-uc .nbg-uc-x:focus-visible {
  outline: 2px solid var(--nbgc-accent-ink, #6ee7b7);
  outline-offset: 2px;
}
