/* Components. Class names match the shared files (ui-core.js, partner-catalog.js) so the menu and campaign forms
   the moderation panel uses look at home here too. */

/* ---- buttons ---------------------------------------------------------------------------------------------- */
.primary-button, .ghost-button, .danger-button, .quiet-button {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: 44px; padding: 0 var(--space-4); border-radius: 12px; border: 1px solid transparent;
  font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: transform var(--duration-fast) var(--ease-out), background var(--duration-fast), box-shadow var(--duration-fast), border-color var(--duration-fast);
}
.primary-button { background: var(--brand); color: var(--on-brand); box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.16), var(--shadow-1); }
.primary-button:hover { background: var(--brand-strong); }
.ghost-button { background: var(--surface); border-color: var(--line-strong); color: var(--ink); }
.ghost-button:hover { border-color: var(--ink-3); background: var(--surface-sunk); }
.danger-button { background: var(--danger-tint); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.danger-button:hover { border-color: var(--danger); }
.quiet-button { background: none; color: var(--ink-2); padding: 0 var(--space-2); min-height: 36px; }
.quiet-button:hover { color: var(--ink); background: var(--surface-sunk); }
.primary-button:active, .ghost-button:active, .danger-button:active { transform: translateY(1px) scale(0.99); }
.primary-button:disabled, .ghost-button:disabled, .danger-button:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.small-button { min-height: 34px; padding: 0 var(--space-3); font-size: var(--text-sm); border-radius: 10px; }
.big-button { min-height: 56px; padding: 0 var(--space-5); font-size: var(--text-lg); border-radius: 16px; }
.icon-button {
  display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); cursor: pointer;
}
.icon-button:hover { color: var(--ink); border-color: var(--line-strong); }

/* ---- fields ------------------------------------------------------------------------------------------------ */
.field-label { display: block; margin: var(--space-4) 0 6px; font-size: var(--text-sm); font-weight: 600; color: var(--ink-2); }
.field-label:first-child { margin-top: 0; }
.field-hint { margin: 6px 0 0; font-size: var(--text-xs); color: var(--ink-2); }
.input, .select, .reason-input {
  width: 100%; min-height: 46px; padding: 10px 14px; border-radius: 12px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
}
.reason-input { min-height: 72px; resize: vertical; }
.input:focus, .select:focus, .reason-input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 18%, transparent); }
.input::placeholder, .reason-input::placeholder { color: var(--ink-3); }
.form-error { margin-top: var(--space-3); color: var(--danger); font-size: var(--text-sm); font-weight: 600; }
.check-list { display: grid; gap: 2px; max-height: 240px; overflow-y: auto; padding: 6px; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--surface); }
.check-row { display: flex; align-items: center; gap: var(--space-3); padding: 8px; border-radius: 8px; cursor: pointer; }
.check-row:hover { background: var(--surface-sunk); }
.check-row input { width: 18px; height: 18px; accent-color: var(--brand); }

/* ---- surfaces ---------------------------------------------------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--space-4) var(--space-5); box-shadow: var(--shadow-1); margin-bottom: var(--space-3); }
.card-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); margin-bottom: var(--space-2); }
.card-head strong { font-size: var(--text-lg); }
.section-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin: var(--space-6) 0 var(--space-3); }
.section-row:first-child { margin-top: 0; }
.section-title { font-size: var(--text-xs); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-2); }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin-top: var(--space-3); }
.actions.tight { margin-top: 0; gap: 6px; }
.stats { display: flex; flex-wrap: wrap; gap: 6px; margin: var(--space-2) 0; }
.stat { padding: 3px 10px; border-radius: 999px; background: var(--surface-sunk); border: 1px solid var(--line); font-size: var(--text-xs); font-weight: 600; color: var(--ink-2); }
.empty { padding: var(--space-6) var(--space-5); border: 1.5px dashed var(--line-strong); border-radius: var(--radius); color: var(--ink-2); text-align: center; background: color-mix(in srgb, var(--surface) 50%, transparent); }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: var(--text-xs); font-weight: 700; letter-spacing: 0.01em; white-space: nowrap; }
.badge-success { background: var(--success-tint); color: var(--success); }
.badge-warn { background: var(--warn-tint); color: var(--warn); }
.badge-danger { background: var(--danger-tint); color: var(--danger); }
.badge-info { background: var(--info-tint); color: var(--info); }
.badge-neutral { background: var(--surface-sunk); color: var(--ink-2); border: 1px solid var(--line); }

.notice { padding: var(--space-3) var(--space-4); border-radius: 12px; font-size: var(--text-sm); line-height: 1.55; margin-bottom: var(--space-3); }
.notice-success { background: var(--success-tint); color: var(--success); }
.notice-success ul { margin: 6px 0 0 18px; padding: 0; }
.notice-danger { background: var(--danger-tint); color: var(--danger); }
.notice-warn { background: var(--warn-tint); color: var(--warn); }
.notice-info { background: var(--info-tint); color: var(--info); }
.limit-preview { display: grid; gap: 2px; margin: var(--space-3) 0 0; }

/* ---- tables ------------------------------------------------------------------------------------------------ */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-1); }
.card > .table { margin: calc(var(--space-2) * -1) 0; }
.table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.table th { text-align: left; font-size: var(--text-xs); font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table td.num, .table th.num { text-align: right; }
.table td.when { white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.table tr.voided td { color: var(--ink-3); text-decoration: line-through; }
.table tr.voided td:last-child { text-decoration: none; }

/* ---- dialogs (ui-core.js) ------------------------------------------------------------------------------------ */
dialog.modal {
  width: min(520px, calc(100vw - 24px)); max-height: min(88dvh, 860px); padding: 0;
  border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow-3); overflow: hidden; display: none; flex-direction: column;
}
dialog.modal[open] { display: flex; animation: modal-in var(--duration) var(--ease-out); }
dialog.modal.modal-wide { width: min(680px, calc(100vw - 24px)); }
dialog.modal::backdrop { background: rgba(10, 16, 13, 0.48); backdrop-filter: blur(3px); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: var(--text-lg); }
.modal-body { padding: var(--space-4) var(--space-5); overflow-y: auto; }
.modal-message { color: var(--ink-2); margin-bottom: var(--space-3); }
.modal-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: var(--space-2); padding: var(--space-3) var(--space-5); border-top: 1px solid var(--line); background: var(--surface-sunk); }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: var(--space-2); }
.chip { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface); cursor: pointer; font-size: var(--text-sm); }
.chip:hover, .chip[aria-pressed="true"] { border-color: var(--brand); color: var(--brand-strong); background: var(--brand-tint); }
.secret-box { padding: var(--space-4); border-radius: 12px; background: var(--ink); color: var(--paper); font-size: 1.375rem; font-weight: 700; letter-spacing: 0.08em; text-align: center; user-select: all; font-variant-numeric: tabular-nums; }
@keyframes modal-in { from { opacity: 0; transform: translateY(12px) scale(0.98); } to { opacity: 1; transform: none; } }

/* ---- toasts ------------------------------------------------------------------------------------------------ */
.toasts { position: fixed; z-index: 60; right: var(--space-4); bottom: var(--space-4); display: grid; gap: var(--space-2); width: min(380px, calc(100vw - 32px)); }
.toast { padding: var(--space-3) var(--space-4); border-radius: 12px; background: var(--ink); color: var(--paper); font-weight: 600; font-size: var(--text-sm); box-shadow: var(--shadow-2); animation: toast-in var(--duration) var(--ease-out); }
.toast-success { background: var(--brand-deep); color: #fff; }
.toast-error { background: var(--danger); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (max-width: 899px) { .toasts { bottom: calc(var(--tabbar) + var(--space-3) + env(safe-area-inset-bottom)); left: var(--space-4); right: var(--space-4); width: auto; } }

/* ---- segmented control (date ranges) ---------------------------------------------------------------------- */
.segmented { display: inline-flex; padding: 3px; gap: 2px; border-radius: 12px; background: var(--surface-sunk); border: 1px solid var(--line); }
.segmented button { min-height: 34px; padding: 0 var(--space-3); border: 0; border-radius: 9px; background: none; color: var(--ink-2); font-weight: 600; font-size: var(--text-sm); cursor: pointer; }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }
