/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px; border-radius: 14px; border: 1px solid transparent;
  font-weight: 600; font-size: 1rem; line-height: 1; text-decoration: none !important; white-space: nowrap;
  background: var(--surface-2); color: var(--text); transition: transform .12s var(--ease), background var(--t), box-shadow var(--t), opacity var(--t);
  -webkit-tap-highlight-color: transparent; user-select: none;
}
.btn:active { transform: scale(.97); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; pointer-events: none; }
.btn-primary { background: var(--accent); color: var(--accent-text); box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 35%, transparent); }
.btn-primary:hover { background: var(--accent-ink); }
.btn-secondary { background: var(--accent-soft); color: var(--accent-ink); }
.btn-secondary:hover { background: var(--accent-soft-2); }
.btn-ghost { background: transparent; border-color: var(--border-2); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-text { background: transparent; color: var(--accent-ink); padding: 0 8px; min-height: 40px; }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger.solid { background: var(--danger); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-whatsapp { background: #25D366; color: #fff; }
.btn-whatsapp:hover { background: #1fb457; }
.btn-sm { min-height: 38px; padding: 0 14px; font-size: .9rem; border-radius: 11px; }
.btn-lg { min-height: 56px; font-size: 1.08rem; border-radius: 16px; }
.btn-block { width: 100%; }
.btn-icon { width: 44px; min-height: 44px; padding: 0; border-radius: 50%; }
.btn-icon.sm { width: 40px; min-height: 40px; }
.btn .icon { width: 1.2em; height: 1.2em; }

/* ---------- Cards / surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 16px; box-shadow: var(--shadow-1); }
.card.flat { box-shadow: none; }
.card.soft { background: var(--surface-2); border-color: transparent; box-shadow: none; }
.card.accent { background: var(--accent-soft); border-color: transparent; box-shadow: none; }
.card-title { display: flex; align-items: center; gap: 8px; font-weight: 700; margin-bottom: 8px; }
.list { display: flex; flex-direction: column; gap: 8px; }
.list-item {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); text-decoration: none !important; color: inherit; transition: background var(--t), transform .12s var(--ease);
}
.list-item:hover { background: var(--surface-2); }
.list-item:active { transform: scale(.99); }
.divider { height: 1px; background: var(--border); margin: 12px 0; }

/* ---------- Badges / chips / avatars ---------- */
.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(--text-2); line-height: 1.5; }
.badge-new { background: var(--accent); color: var(--accent-text); }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-info { background: var(--info-soft); color: var(--info); }
.chip {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 16px; border-radius: 12px;
  border: 1px solid var(--border-2); background: var(--surface); font-weight: 600; cursor: pointer; transition: all var(--t); font-variant-numeric: tabular-nums;
  -webkit-tap-highlight-color: transparent;
}
.chip:hover { border-color: var(--accent); }
.chip.selected, .chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.chip.disabled { opacity: .4; pointer-events: none; }
.chip-group { display: flex; flex-wrap: wrap; gap: 8px; }
.avatar {
  width: 44px; height: 44px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; flex: none;
  font-weight: 700; color: #fff; background: var(--accent); font-size: 1.05rem; overflow: hidden;
}
.avatar.lg { width: 64px; height: 64px; font-size: 1.5rem; }
.avatar.xl { width: 88px; height: 88px; font-size: 2rem; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.emoji-circle { width: 48px; height: 48px; border-radius: 16px; display: inline-flex; align-items: center; justify-content: center; font-size: 1.5rem; flex: none; background: var(--surface-2); }
.emoji-circle.lg { width: 60px; height: 60px; font-size: 1.9rem; border-radius: 20px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > label, .label { font-weight: 600; font-size: .92rem; }
.field .hint { font-size: .8rem; color: var(--text-2); }
.input, .select, .textarea {
  width: 100%; min-height: 48px; padding: 10px 14px; border-radius: 13px; border: 1.5px solid var(--border-2); background: var(--surface);
  transition: border var(--t), box-shadow var(--t); appearance: none; -webkit-appearance: none;
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.input.error { border-color: var(--danger); }
.input[type="time"], .input[type="date"], .input[type="number"], .input[type="tel"], .input[type="email"] { direction: ltr; text-align: right; }
.input.ltr { direction: ltr; text-align: left; }
.textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
.select { background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%237A6B70' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='m6 9 6 6 6-6'/></svg>"); background-repeat: no-repeat; background-position: left 12px center; padding-left: 36px; }
.input-row { display: flex; gap: 8px; align-items: center; }
.input-row .input { flex: 1; min-width: 0; }
.input-row > span { overflow-wrap: anywhere; min-width: 0; }
.form-error { color: var(--danger); font-size: .875rem; margin-top: 4px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
@media (max-width: 480px) { .form-grid { grid-template-columns: 1fr; } }
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; min-height: 44px; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track { width: 48px; height: 28px; border-radius: 14px; background: var(--border-2); position: relative; transition: background var(--t); flex: none; }
.switch .track::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform var(--t) var(--ease); }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(-20px); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 4px var(--accent-soft); }
.checkbox { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; cursor: pointer; }
.checkbox input { width: 20px; height: 20px; accent-color: var(--accent); }
.segmented { display: inline-flex; background: var(--surface-2); border-radius: 12px; padding: 3px; gap: 2px; }
.segmented button { border: 0; background: transparent; padding: 0 14px; min-height: 36px; border-radius: 10px; font-weight: 600; color: var(--text-2); transition: all var(--t); }
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }
.color-swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.color-swatches button { width: 36px; height: 36px; border-radius: 50%; border: 3px solid transparent; cursor: pointer; transition: transform .12s; }
.color-swatches button.selected { border-color: var(--text); transform: scale(1.1); }
.color-swatches input[type="color"] { width: 36px; height: 36px; border-radius: 50%; border: 0; padding: 0; background: none; cursor: pointer; }
.emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 6px; }
.emoji-grid button { height: 48px; border-radius: 12px; border: 1.5px solid var(--border); background: var(--surface); font-size: 1.4rem; }
.emoji-grid button.selected { border-color: var(--accent); background: var(--accent-soft); }

/* ---------- Bottom sheet / side panel ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: var(--overlay); z-index: 80; opacity: 0; transition: opacity var(--t); backdrop-filter: blur(2px); touch-action: none; }
.sheet-backdrop.open { opacity: 1; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 81; background: var(--surface); border-radius: var(--r-xl) var(--r-xl) 0 0;
  box-shadow: var(--shadow-2); max-height: 92dvh; display: flex; flex-direction: column; transform: translateY(100%);
  transition: transform 280ms var(--ease); padding-bottom: var(--safe-b);
}
.sheet.open { transform: none; }
.sheet-handle { width: 40px; height: 5px; border-radius: 3px; background: var(--border-2); margin: 10px auto 2px; flex: none; }
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 8px 16px; flex: none; }
.sheet-head h2 { margin: 0; flex: 1; font-size: 1.15rem; }
.sheet-body { overflow: auto; padding: 4px 16px 20px; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.sheet-foot { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; gap: 8px; flex: none; }
@media (min-width: 900px) {
  .sheet { left: 0; right: auto; top: 0; bottom: 0; width: 460px; max-height: none; border-radius: 0 var(--r-xl) var(--r-xl) 0; transform: translateX(-100%); }
  .sheet-handle { display: none; }
  .sheet-head { padding-top: 16px; }
}

/* ---------- Toast ---------- */
#toasts { position: fixed; top: calc(12px + var(--safe-t)); left: 0; right: 0; z-index: 100; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
.toast {
  pointer-events: auto; background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 14px; box-shadow: var(--shadow-2); font-weight: 600;
  display: flex; align-items: center; gap: 8px; max-width: 480px; animation: toastIn .3s var(--ease);
}
.toast.success { background: var(--success); color: #fff; }
.toast.error { background: var(--danger); color: #fff; }
.toast.leaving { animation: toastOut .25s var(--ease) forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-12px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-8px); } }

/* ---------- Stepper ---------- */
.stepper { display: flex; align-items: center; gap: 6px; margin: 4px 0 18px; }
.stepper .s { flex: 1; height: 5px; border-radius: 3px; background: var(--border); transition: background var(--t); }
.stepper .s.done, .stepper .s.active { background: var(--accent); }
.stepper .s.active { box-shadow: 0 0 0 3px var(--accent-soft); }
.step-title { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.step-title h2 { margin: 0; }
.step-title .n { width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: #fff; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; font-size: .9rem; flex: none; }

/* ---------- Skeleton / empty ---------- */
.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 10px; min-height: 18px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.empty { text-align: center; padding: 32px 16px; color: var(--text-2); }
.empty .big { font-size: 2.4rem; margin-bottom: 8px; }
.spinner { width: 22px; height: 22px; border: 3px solid var(--accent-soft-2); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Alerts ---------- */
.alert { padding: 12px 14px; border-radius: 14px; background: var(--info-soft); color: var(--text); display: flex; gap: 10px; align-items: flex-start; font-size: .95rem; }
.alert .icon { margin-top: 2px; color: var(--info); }
.alert.success { background: var(--success-soft); } .alert.success .icon { color: var(--success); }
.alert.warning { background: var(--warning-soft); } .alert.warning .icon { color: var(--warning); }
.alert.danger { background: var(--danger-soft); } .alert.danger .icon { color: var(--danger); }

/* ---------- Tables (admin) ---------- */
.table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.table th, .table td { padding: 12px 10px; text-align: right; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { color: var(--text-2); font-weight: 600; font-size: .82rem; }
.table tr:hover td { background: var(--surface-2); }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ---------- Copy field ---------- */
.copy-field { display: flex; gap: 6px; align-items: center; background: var(--surface-2); border-radius: 12px; padding: 6px 6px 6px 12px; }
.copy-field code { flex: 1; direction: ltr; text-align: left; font-size: .82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.kbd { font-family: ui-monospace, monospace; background: var(--surface-2); padding: 1px 6px; border-radius: 6px; font-size: .85em; }
