/* Reusable components: buttons, inputs, cards, badges, banner, toast, dialog, skeleton. */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); min-width: var(--tap); padding: 8px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font-weight: 600; cursor: pointer;
}
.btn svg { width: 20px; height: 20px; flex: none; }
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-danger { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.btn-warn { background: var(--paused-strong); border-color: var(--paused-strong); color: #1d1300; }
.btn-warn:hover { background: var(--paused-strong); filter: brightness(1.06); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-icon { padding: 8px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.is-busy { position: relative; cursor: progress; }
.btn.is-busy::after {
  content: ""; width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-inline-end-color: transparent;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.btn-row > .btn-grow { flex: 1 1 120px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card > * + * { margin-top: 12px; }
.card-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .field-label { font-weight: 600; font-size: .9rem; }
.field-hint { color: var(--muted); font-size: .85rem; }
.field-error { color: var(--danger); font-size: .88rem; font-weight: 600; }
.input, .select, .textarea {
  width: 100%; min-height: var(--tap); padding: 9px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
}
.textarea { min-height: 160px; line-height: 1.5; resize: vertical; }
.input[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--danger); }
.input-row { display: flex; align-items: center; gap: 8px; }
.input-unit { color: var(--muted); font-size: .85rem; white-space: nowrap; }

.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px;
  font-size: .75rem; font-weight: 700; background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.badge-live { background: var(--live-soft); color: var(--live); }
.badge-paused { background: var(--paused-soft); color: var(--paused); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-accent { background: var(--accent-soft); color: var(--accent); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }

.seg { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.seg button { min-height: var(--tap); min-width: 64px; padding: 6px 14px; border: 0; background: var(--surface); font-weight: 600; cursor: pointer; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.seg button:disabled { opacity: .55; cursor: not-allowed; }

/* Status banner under the header: paused / WhatsApp offline / server unreachable */
.banner { padding: 10px var(--gutter); font-weight: 600; text-align: center; background: var(--surface-2); }
.banner-paused { background: var(--paused-strong); color: #1d1300; border-bottom: 3px solid #1d1300; }
.banner-warn { background: var(--paused-soft); color: var(--paused); }
.banner-danger { background: var(--danger-soft); color: var(--danger); }
.banner .btn { margin-inline-start: 10px; }

.empty { text-align: center; padding: 32px 16px; color: var(--muted); border: 1px dashed var(--border); border-radius: var(--radius); }
.empty strong { display: block; color: var(--text); margin-bottom: 4px; }
.error-box { padding: 14px; border-radius: var(--radius); background: var(--danger-soft); color: var(--danger); display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.error-box ul { padding-inline-start: 18px; list-style: disc; font-size: .9rem; }
.notice { padding: 10px 12px; border-radius: var(--radius-sm); background: var(--paused-soft); color: var(--paused); font-size: .9rem; }

.skeleton { border-radius: var(--radius); height: 88px; background: linear-gradient(90deg, var(--surface-2), var(--surface), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
.skeleton + .skeleton { margin-top: 12px; }
@keyframes shimmer { to { background-position: -200% 0; } }

.toasts { position: fixed; z-index: 100; inset-inline: 12px; bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { pointer-events: auto; max-width: 480px; padding: 10px 16px; border-radius: var(--radius-sm); background: var(--text); color: var(--bg); box-shadow: var(--shadow); font-size: .92rem; font-weight: 600; animation: pop .18s ease-out; }
.toast-error { background: var(--danger); color: #fff; }
.toast-ok { background: var(--live); color: #fff; }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }
@media (min-width: 840px) { .toasts { bottom: 24px; } }

.modal { width: min(480px, calc(100vw - 24px)); max-height: 90dvh; padding: 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.modal::backdrop { background: rgba(10, 12, 18, .55); }
.modal-box { padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.modal-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.modal-actions .btn { flex: 1 1 120px; }
