/* ==== DocForge — buttons, cards, forms, tables, pills, toasts ==== */

/* ---------------------------------------------------------------- buttons --*/

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 7px 13px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--txt-2);
  font-size: 13.5px;
  font-weight: 550;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: var(--shadow-xs), inset 0 1px 0 rgba(255, 255, 255, .7);
  transition: background var(--transition), border-color var(--transition),
              color var(--transition), box-shadow var(--transition),
              transform var(--transition);
}
.btn:hover:not(:disabled) {
  background: #F4F8FB;
  border-color: var(--pri-border);
  color: var(--pri);
  text-decoration: none;
}
.btn:active:not(:disabled) { box-shadow: none; transform: translateY(.5px); }
.btn:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }

/* The primary button carries the brand ramp with a hairline highlight along
   its top edge — the same treatment as the sidebar mark, so they read as kin. */
.btn-primary {
  background: var(--grad-btn);
  border-color: var(--pri-hover);
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .22), 0 1px 2px rgba(31, 95, 139, .35);
}
.btn-primary:hover:not(:disabled) {
  background: var(--grad-btn-hover);
  border-color: var(--pri-hover);
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .18), var(--shadow-pri);
  transform: translateY(-.5px);
}
.btn-primary:active:not(:disabled) {
  transform: translateY(.5px);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, .2);
}

.btn-danger { background: var(--grad-danger); border-color: #8F1E17; color: #fff; }
.btn-danger:hover:not(:disabled) { background: #8F1E17; border-color: #8F1E17; color: #fff; }
.btn-danger-ghost { color: var(--danger); }
.btn-danger-ghost:hover:not(:disabled) {
  background: var(--danger-soft);
  border-color: var(--danger-border);
  color: var(--danger);
}

.btn-ghost { border-color: transparent; background: transparent; box-shadow: none; }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); border-color: transparent; }

/* A button that sits on a gradient surface. */
.btn-glass { background: var(--glass-dark-bg); border-color: var(--glass-dark-border); color: #fff; box-shadow: none; }
.btn-glass:hover:not(:disabled) { background: rgba(255, 255, 255, .22); border-color: rgba(255, 255, 255, .45); color: #fff; }

.btn-sm { padding: 4px 9px; font-size: 12.5px; gap: 5px; }
.btn-lg { padding: 10px 18px; font-size: 14.5px; }
.btn-block { width: 100%; }
.btn-icon { padding: 6px; }

/* ------------------------------------------------------------------ cards --*/

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}
.card + .card { margin-top: 14px; }
.card-pad-0 { padding: 0; overflow: hidden; }
/* Cards that are themselves a target lift on hover; static cards stay put. */
.card-interactive {
  transition: box-shadow var(--transition), transform var(--transition), border-color var(--transition);
}
.card-interactive:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); border-color: var(--pri-border); }

.card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 650;
  letter-spacing: -.005em;
  margin-bottom: 14px;
  color: var(--txt);
}
.card-title .icon { color: var(--txt-faint); }
.card-title .spacer { flex: 1; }
.card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--border);
}
.card-head h3 { margin: 0; font-size: 13.5px; font-weight: 650; }
.card-body { padding: 18px; }

/* A tinted well behind a section icon. */
.icon-well {
  width: 30px; height: 30px;
  flex: 0 0 30px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: var(--grad-well);
  color: var(--pri);
  box-shadow: inset 0 0 0 1px rgba(31, 95, 139, .08);
}
.card-title .icon-well { margin-right: 2px; }
.card-title .icon-well .icon { color: var(--pri); }

/* --------------------------------------------------------------- stat tiles --*/

.stat-grid {
  display: grid;
  /* 190px lands on four columns at the usual content width, so eight tiles
     read as two even rows rather than five-then-three. */
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}
.stat {
  background: linear-gradient(180deg, #FFFFFF 0%, #FBFCFD 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 15px;
  box-shadow: var(--shadow);
}
.stat-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--txt-faint);
  margin-bottom: 7px;
}
.stat-value {
  font-size: 24px;
  font-weight: 650;
  letter-spacing: -.02em;
  line-height: 1.1;
  color: var(--txt);
}
.stat-sub { font-size: 12px; color: var(--txt-muted); margin-top: 3px; }

/* ------------------------------------------------------------------ forms --*/

.field { margin-bottom: 15px; }
.field:last-child { margin-bottom: 0; }
.field label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  margin-bottom: 5px;
  color: var(--txt-2);
}
.field .hint { font-size: 12px; color: var(--txt-muted); margin-top: 5px; }

.field-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0 14px;
}

.input, .select, .textarea {
  width: 100%;
  padding: 7px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: inset 0 1px 1px rgba(16, 24, 40, .03);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.input::placeholder, .textarea::placeholder { color: var(--txt-faint); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--txt-faint); }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--pri);
  box-shadow: var(--ring);
}
.textarea { min-height: 92px; resize: vertical; line-height: 1.55; }
.input.invalid, .textarea.invalid { border-color: var(--danger); }
.input.invalid:focus, .textarea.invalid:focus { box-shadow: var(--ring-danger); }

.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%235D6874' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  padding-right: 30px;
}

.input-group { position: relative; display: flex; align-items: center; }
.input-group .icon {
  position: absolute;
  left: 10px;
  color: var(--txt-faint);
  pointer-events: none;
}
.input-group .input { padding-left: 32px; }

.form-error, .form-note {
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 13px;
  margin-bottom: 14px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.form-error { background: var(--danger-soft); border: 1px solid var(--danger-border); color: var(--danger); }
.form-note { background: var(--pri-soft); border: 1px solid var(--pri-border); color: var(--pri); }

.save-state {
  font-size: 12px;
  color: var(--txt-faint);
  display: flex;
  align-items: center;
  gap: 5px;
  min-height: 18px;
}

/* Font chips: each family shown in its own face (served at /fonts/…). Two
   columns fit the document panel's 300–360px sidebar; the group labels span. */
.font-chips { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.font-chip-group {
  grid-column: 1 / -1;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--txt-faint);
  margin-top: 6px;
}
.font-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  text-align: left;
  cursor: pointer;
  color: var(--txt);
  transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
}
.font-chip:hover { border-color: var(--pri-border); background: #F8FAFC; }
.font-chip.active { border-color: var(--pri); background: var(--pri-soft); box-shadow: 0 0 0 3px var(--pri-soft); }
.font-chip-sample {
  flex: 0 0 30px;
  font-size: 21px;
  line-height: 1;
  text-align: center;
  color: var(--txt);
}
.font-chip-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.font-chip-name {
  font-size: 12.5px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.font-chip-note {
  font-family: var(--font);
  font-size: 10.5px;
  color: var(--txt-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.font-chip.is-default .font-chip-note { color: var(--pri); }

/* A list of tickable rows — used for the document's closing-page notices. */
.check-list { display: flex; flex-direction: column; gap: 6px; }
.check-item {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}
.check-item:hover { border-color: var(--pri-border); background: #F8FAFC; }
.check-item:has(input:checked) { border-color: var(--pri-border); background: var(--pri-soft); }
.check-item input { margin: 2px 0 0; width: 15px; height: 15px; flex: 0 0 15px; accent-color: var(--pri); }
.check-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.check-title { font-size: 13px; font-weight: 600; }
.check-sub { font-size: 11.5px; color: var(--txt-faint); }
.save-state.saved { color: var(--ok); }
.save-state.failed { color: var(--danger); }

/* ------------------------------------------------------------------ pills --*/

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--txt-muted);
  white-space: nowrap;
  border: 1px solid transparent;
}
.pill-ok { background: var(--ok-soft); color: var(--ok); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-err { background: var(--danger-soft); color: var(--danger); }
.pill-info { background: var(--pri-soft); color: var(--pri); }
.pill-brand { background: var(--grad-brand); color: #fff; }
/* On a gradient surface. */
.pill-glass { background: rgba(255, 255, 255, .16); color: #fff; border-color: rgba(255, 255, 255, .32); }
.pill-dot::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex: 0 0 6px;
}

/* ----------------------------------------------------------------- tables --*/

.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th {
  text-align: left;
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--txt-faint);
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  white-space: nowrap;
}
.data-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: 0; }
.data-table tbody tr { transition: background var(--transition); }
.data-table tbody tr:hover { background: var(--surface-2); }
.data-table .row-actions {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
  opacity: 0;
  transition: opacity var(--transition);
}
.data-table tr:hover .row-actions,
.data-table tr:focus-within .row-actions { opacity: 1; }
.table-scroll { overflow-x: auto; }

/* ------------------------------------------------------------ empty state --*/

.empty { text-align: center; padding: 52px 24px; color: var(--txt-muted); }
.empty .glyph {
  width: 56px; height: 56px;
  margin: 0 auto 14px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--grad-well);
  color: var(--pri);
  box-shadow: inset 0 0 0 1px rgba(31, 95, 139, .08), 0 6px 16px rgba(31, 95, 139, .10);
}
.empty h3 { color: var(--txt); margin-bottom: 6px; font-size: 15.5px; }
.empty p { max-width: 420px; margin: 0 auto 18px; }

/* ---------------------------------------------------------------- toasts --*/

#toast-host {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  z-index: 200;
}
.toast {
  background: rgba(20, 24, 31, .92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #fff;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, .08);
  box-shadow: var(--shadow-xl);
  font-size: 13px;
  max-width: 360px;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toast-in 220ms var(--ease-spring);
}
.toast-err { background: rgba(179, 38, 30, .94); }
.toast-ok { background: rgba(27, 122, 75, .94); }
.toast button {
  background: none;
  border: 0;
  color: inherit;
  opacity: .7;
  cursor: pointer;
  padding: 0 2px;
  display: flex;
}
.toast button:hover { opacity: 1; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }

/* --------------------------------------------------------------- skeleton --*/

.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }

/* ----------------------------------------------------------------- modal --*/

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 40, .48);
  backdrop-filter: blur(6px) saturate(120%);
  -webkit-backdrop-filter: blur(6px) saturate(120%);
  display: grid;
  place-items: center;
  padding: 24px;
  z-index: 300;
  animation: fade-in 140ms ease;
}
.modal {
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 440px;
  animation: modal-in 220ms var(--ease-spring);
}
.modal-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 22px 0;
}
.modal-head h3 { margin: 0; font-size: 15.5px; }
.modal-head .icon { color: var(--txt-muted); }
.modal-body { padding: 14px 22px; }
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 0 22px 20px;
}
@keyframes fade-in { from { opacity: 0; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(14px) scale(.97); } }
