/* PawnSoft admin — additions on top of the Adminator 2026 template.
   The template ships static demo markup for modals (.modal-demo) but no
   JS to actually open/close one, and no toast component at all. These
   rules add just that, reusing the template's own tokens so it matches
   exactly instead of introducing a second visual language. */

.ps-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  z-index: 200;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 8vh 16px 16px;
  opacity: 0;
  visibility: hidden;
  transition: opacity .2s ease, visibility .2s;
}
.ps-modal-overlay.is-open { opacity: 1; visibility: visible; }

.ps-modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 480px;
  overflow: hidden;
  transform: translateY(-8px);
  transition: transform .2s ease;
  max-height: 82vh;
  display: flex;
  flex-direction: column;
}
.ps-modal-overlay.is-open .ps-modal { transform: translateY(0); }

.ps-modal .modal-body { overflow-y: auto; }

.ps-modal .close-x {
  background: none;
  border: none;
  color: var(--t-muted);
  cursor: pointer;
  line-height: 1;
  padding: 4px;
  display: inline-flex;
}
.ps-modal .close-x svg { width: 18px; height: 18px; }

/* Toasts */
#ps-toasts {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ps-toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary, #6366f1);
  border-radius: 10px;
  padding: 11px 14px;
  font-size: 13px;
  color: var(--t-base);
  min-width: 240px;
  max-width: 340px;
  box-shadow: var(--shadow-lg);
  animation: ps-toast-in .18s ease;
}
.ps-toast.err { border-left-color: var(--danger, #ef4444); }
@keyframes ps-toast-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.ps-spinner {
  width: 16px; height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--primary, #6366f1);
  border-radius: 50%;
  display: inline-block;
  animation: ps-spin .7s linear infinite;
}
@keyframes ps-spin { to { transform: rotate(360deg); } }

.ps-loading-row td { padding: 30px; text-align: center; color: var(--t-light); }

/* compact select used inside data-toolbar-right (matches template sizing) */
.data-toolbar-right select.select { width: auto; padding: 7px 28px 7px 10px; font-size: 12px; }

/* template ships c-success/c-danger/c-purple/c-primary only */
.kpi-card.c-info { color: var(--info); }

/* 5-up KPI grid variant (template ships a 4-up .kpi-grid only) */
.kpi-grid.cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
@media (max-width: 1100px) {
  .kpi-grid.cols-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
  .kpi-grid.cols-5, .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Limit / usage bar shown on client rows and the companies drawer */
.ps-limit-bar {
  background: var(--bg-muted);
  border-radius: 999px;
  height: 5px;
  width: 100%;
  overflow: hidden;
  margin-top: 5px;
}
.ps-limit-bar-fill { height: 100%; border-radius: 999px; background: var(--primary); }
.ps-limit-bar-fill.warn { background: var(--warning); }
.ps-limit-bar-fill.full { background: var(--danger); }
.ps-limit-text { font-size: 11px; color: var(--t-light); margin-top: 3px; }

/* Section headers inside the big client form (mirrors forms.html .section-h) */
.ps-form-section {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--t-light);
  font-weight: 600;
  margin: 22px 0 10px;
  padding-top: 14px;
  border-top: 1px solid var(--border-soft);
}
.ps-form-section:first-child { margin-top: 0; padding-top: 0; border-top: none; }

.ps-modal.wide { max-width: 720px; }

/* view toggling within a single page (list / wizard / detail) */
[data-ps-view] { display: none; }
[data-ps-view].is-active { display: block; }

/* Step wizard header — icon avatar + "STEP N / Title" label, connected
   by a line that spans the full width. */
.ps-steps {
  display: flex;
  align-items: center;
  padding: 22px 28px;
  border-bottom: 1px solid var(--border-soft);
}
.ps-step {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}
.ps-step-icon {
  width: 48px; height: 48px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-muted);
  color: var(--t-light);
  border: 1px solid var(--border);
  flex-shrink: 0;
  transition: background .15s, border-color .15s, color .15s;
}
.ps-step-icon svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.ps-step.is-active .ps-step-icon { background: var(--primary); border-color: var(--primary); color: #fff; }
.ps-step.is-done .ps-step-icon { background: var(--success); border-color: var(--success); color: #fff; }
.ps-step-text { display: flex; flex-direction: column; gap: 1px; }
.ps-step-eyebrow {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .07em;
  font-weight: 700;
  color: var(--t-light);
}
.ps-step.is-active .ps-step-eyebrow { color: var(--primary); }
.ps-step.is-done .ps-step-eyebrow { color: var(--success); }
.ps-step-title { font-size: 14px; font-weight: 600; color: var(--t-light); white-space: nowrap; }
.ps-step.is-active .ps-step-title,
.ps-step.is-done .ps-step-title { color: var(--t-base); }
.ps-step-line {
  flex: 1 1 auto;
  min-width: 24px;
  height: 1px;
  background: var(--border);
  margin: 0 22px;
  transition: background .15s;
}
.ps-step-line.is-done { background: var(--success); }
@media (max-width: 760px) {
  .ps-step-text { display: none; }
  .ps-step.is-active .ps-step-text { display: flex; }
}

.ps-wizard-panel { padding: 18px 24px 8px; }
.ps-wizard-panel[hidden] { display: none; }

/* Footer sticks to the bottom of the viewport when page content is short,
   and flows normally below content when it's taller than the viewport. */
.main { min-height: 100vh; }
.content { flex: 1 0 auto; }

.ps-wizard-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px 20px;
  border-top: 1px solid var(--border-soft);
  margin-top: 8px;
}

/* Read-only detail view */
.ps-detail-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px 28px; padding: 4px 22px 20px; }
.ps-detail-grid.span-full { grid-template-columns: 1fr; }
.ps-detail-item .k { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--t-light); margin-bottom: 3px; }
.ps-detail-item .v { font-size: 13.5px; color: var(--t-base); }
.ps-detail-item .v.mono { font-family: 'JetBrains Mono', monospace; }
.ps-detail-item .v.empty { color: var(--t-light); font-style: italic; }
@media (max-width: 700px) { .ps-detail-grid { grid-template-columns: 1fr; } }

.cell-sub-line { color: var(--t-light); font-size: 11px; margin-top: 4px; }

/* template ships .col-6/.col-12 only */
.col-4 { grid-column: span 4; }
@media (max-width: 900px) { .col-4 { grid-column: span 12; } }

/* Field validation states (Bootstrap-style: red border + message when
   invalid, green border when a value has been entered and passes its
   check — applied to every field the user interacts with, not just
   ones marked required). */
.field.has-error .input,
.field.has-error .select {
  border-color: var(--danger);
  background: var(--danger-soft);
}
.field.has-error .input:focus,
.field.has-error .select:focus {
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--danger) 18%, transparent);
}
.field.has-success .input,
.field.has-success .select {
  border-color: var(--success);
}
.field.has-success .input:focus,
.field.has-success .select:focus {
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--success) 18%, transparent);
}
.field-error-msg {
  display: none;
  color: var(--danger);
  font-size: 11.5px;
  margin-top: 5px;
}
.field.has-error .field-error-msg { display: block; }
.field.has-error .field-help { display: none; }

/* ===================== v7 additions ===================== */
.ps-hidden { display: none !important; }

/* 3-up KPI grid (dashboard now has 6 cards) */
.kpi-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 900px) { .kpi-grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
a.kpi-card { color: inherit; }
a.kpi-card:hover { transform: translateY(-2px); border-color: var(--primary); }

.ps-link { color: inherit; text-decoration: none; }
.ps-link:hover strong { color: var(--primary); text-decoration: underline; text-underline-offset: 3px; }

/* chips / tags */
.ps-chip-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.ps-chip {
  border: 1px solid var(--border); background: var(--bg-card); color: var(--t-base);
  border-radius: 999px; padding: 4px 11px; font-size: 12px; cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.ps-chip:hover { border-color: var(--primary); color: var(--primary); }
.ps-tag {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--bg-muted); border-radius: 6px; padding: 3px 8px;
  font-size: 11.5px; color: var(--t-base);
}
.ps-tag em { color: var(--t-light); font-style: normal; font-size: 10.5px; }

.ps-check { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; color: var(--t-base); margin: 4px 0 8px; cursor: pointer; line-height: 1.4; }
.ps-check input { margin-top: 3px; accent-color: var(--primary); flex-shrink: 0; }
.ps-check .cell-muted { font-size: 12px; }

/* token text box */
.ps-token-box {
  font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 11.5px; line-height: 1.5;
  width: 100%; resize: vertical; word-break: break-all; min-height: 96px;
}

/* issue preview */
.ps-preview { background: var(--bg-muted); border-radius: 10px; padding: 14px 16px; font-size: 13px; }
.ps-preview-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px 22px; }
@media (max-width: 600px) { .ps-preview-grid { grid-template-columns: 1fr; } }
.ps-detail-item .v.ps-over { color: var(--danger); font-weight: 600; }

/* compact tables inside modals */
.data-table.ps-mini { font-size: 12.5px; margin-bottom: 6px; }
.data-table.ps-mini th, .data-table.ps-mini td { padding: 7px 10px; }

.ps-raw { margin-top: 18px; }
.ps-raw summary { cursor: pointer; font-size: 12px; color: var(--t-muted); }
.ps-json {
  background: var(--bg-muted); border-radius: 8px; padding: 12px; margin-top: 8px;
  font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 11.5px;
  max-height: 320px; overflow: auto; white-space: pre; color: var(--t-base);
}

/* dashboard "needs attention" + activity feed */
.ps-attn-list { padding: 2px 12px 14px; display: flex; flex-direction: column; }
.ps-attn {
  display: flex; gap: 12px; align-items: flex-start; padding: 10px; border-radius: 8px;
  text-decoration: none; color: var(--t-base); font-size: 13px;
}
a.ps-attn:hover { background: var(--bg-hover, var(--bg-muted)); }
.ps-attn .dotx { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex-shrink: 0; background: var(--t-light); }
.ps-attn.danger .dotx { background: var(--danger); }
.ps-attn.warning .dotx { background: var(--warning); }
.ps-attn.info .dotx { background: var(--info); }
.ps-attn strong { font-weight: 600; }
.ps-attn-empty { padding: 26px 10px; text-align: center; color: var(--t-light); font-size: 13px; }

.ps-pager-row { display: flex; justify-content: space-between; align-items: center; padding: 14px 0 4px; gap: 10px; flex-wrap: wrap; }
.cell-muted { color: var(--t-light); }

/* btn used as <a> inside action cells */
.data-cell-actions a.btn--icon { display: inline-grid; place-items: center; }
.modal-foot { gap: 10px; }

/* inline icons inside text/tags: outline style like the rest of the UI */
.ps-tag svg, .cell-sub-line svg, .data-cell-mono svg { fill: none; stroke: currentColor; stroke-width: 2; }
.ps-attn .cell-sub-line { display: block; margin-top: 2px; }
/* alerts generated without an icon: let the body use the full width */
.alert.no-ico { grid-template-columns: 1fr; }
.ps-preview .ps-tag { background: var(--bg-card); border: 1px solid var(--border); }

/* ===================== v8 additions ===================== */
.ps-key-display {
  font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 17px; letter-spacing: .5px;
  background: var(--bg-muted); border: 1px dashed var(--border); border-radius: 10px;
  padding: 16px; text-align: center; color: var(--t-base); word-break: break-all; user-select: all;
}
.ps-db-modes { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
@media (max-width: 760px) { .ps-db-modes { grid-template-columns: 1fr; } }
.ps-db-mode {
  display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--border); border-radius: 12px;
  padding: 14px; cursor: pointer; transition: border-color .15s, background .15s;
}
.ps-db-mode:hover { border-color: var(--primary); }
.ps-db-mode:has(input:checked) { border-color: var(--primary); background: color-mix(in oklab, var(--primary) 6%, transparent); }
.ps-db-mode input { margin-top: 4px; accent-color: var(--primary); }
.ps-db-mode b { display: block; font-size: 13.5px; margin-bottom: 3px; color: var(--t-base); }
.ps-db-mode .cell-muted { display: block; font-size: 12px; line-height: 1.45; }
.ps-db-mode.is-disabled { opacity: .6; cursor: not-allowed; }
.ps-chip-static { font-size: 12px; color: var(--t-muted); background: var(--bg-muted); border-radius: 999px; padding: 4px 12px; }
#acTabs { margin: 0 0 4px; }
.ps-detail-item.span-full { grid-column: 1 / -1; }
