/* ═══════════════════════════════════════════════════════════════════
   COMPONENTES — botões, cards, inputs, badges, avatars, forms
   ═══════════════════════════════════════════════════════════════════ */

/* ── Botões ─────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--r10);
  font-size: 14px;
  font-weight: 600;
  border: 1.5px solid transparent;
  transition: background var(--transition), color var(--transition),
              border-color var(--transition), box-shadow var(--transition),
              transform var(--transition);
  white-space: nowrap;
  text-decoration: none !important;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--p);
  color: #fff;
  border-color: var(--p);
}
.btn-primary:hover {
  background: var(--ph);
  border-color: var(--ph);
  box-shadow: 0 4px 12px rgba(249,115,22,.35);
  text-decoration: none;
  color: #fff;
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--ink-2);
  border-color: var(--line);
}
.btn-secondary:hover {
  background: var(--line);
  color: var(--ink-1);
  text-decoration: none;
}

.btn-outline {
  background: transparent;
  color: var(--p);
  border-color: var(--p);
}
.btn-outline:hover {
  background: var(--pb);
  text-decoration: none;
  color: var(--ph);
}

.btn-ghost {
  background: transparent;
  color: var(--ink-2);
  border-color: transparent;
}
.btn-ghost:hover {
  background: var(--surface-2);
  color: var(--ink-1);
  text-decoration: none;
}

.btn-danger {
  background: color-mix(in oklch, var(--red) 8%, transparent);
  color: var(--red);
  border-color: color-mix(in oklch, var(--red) 25%, transparent);
}
.btn-danger:hover {
  background: color-mix(in oklch, var(--red) 14%, transparent);
  text-decoration: none;
}

.btn-sm  { padding: 6px 14px;  font-size: 13px; }
.btn-lg  { padding: 14px 28px; font-size: 16px; }
.btn-xl  { padding: 16px 32px; font-size: 17px; }
.btn-full { width: 100%; justify-content: center; }

.btn:disabled, .btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.btn .btn-icon { width: 18px; height: 18px; flex-shrink: 0; }

/* ── Inputs e formulários ───────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
}

.form-input {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--line-2);
  border-radius: var(--r10);
  font-size: 16px; /* 16px é essencial — previne zoom iOS ao focar */
  color: var(--ink-1);
  background: var(--bg);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
.form-input::placeholder { color: var(--ink-4); }
.form-input:focus {
  border-color: var(--p);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--p) 15%, transparent);
}
.form-input:invalid:not(:placeholder-shown) {
  border-color: var(--red);
}
.form-input.has-error { border-color: var(--red); }

.form-input-wrap {
  position: relative;
}
.form-input-wrap .input-icon-left,
.form-input-wrap .form-input-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-4);
  pointer-events: none;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.form-input-wrap .input-icon-right {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-4);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.form-input-wrap .input-icon-right:hover { color: var(--ink-2); }
.form-input-wrap.has-left  .form-input { padding-left: 42px; }
.form-input-wrap.has-right .form-input { padding-right: 42px; }

.form-error {
  font-size: 12px;
  color: var(--red);
  display: flex;
  align-items: center;
  gap: 4px;
}

.form-hint {
  font-size: 12px;
  color: var(--ink-4);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

select.form-input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394A3B8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 40px;
  cursor: pointer;
}

textarea.form-input {
  resize: vertical;
  min-height: 100px;
}

/* Checkbox e Radio customizados */
.form-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
}
.form-check input[type="checkbox"],
.form-check input[type="radio"] {
  width: 18px;
  height: 18px;
  accent-color: var(--p);
  flex-shrink: 0;
  margin-top: 2px;
  cursor: pointer;
}
.form-check-label {
  font-size: 14px;
  color: var(--ink-2);
  line-height: 1.5;
}

/* Toggle switch */
.toggle-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}
.toggle-track {
  position: relative;
  width: 44px;
  height: 24px;
  background: var(--line-2);
  border-radius: var(--rf);
  transition: background var(--transition);
  flex-shrink: 0;
}
.toggle-track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  box-shadow: var(--sh-sm);
  transition: transform var(--transition);
}
.toggle-track.active {
  background: var(--p);
}
.toggle-track.active::after {
  transform: translateX(20px);
}

/* ── Cards ───────────────────────────────────────────────────────────── */
.card {
  background: var(--card-bg);
  border-radius: var(--r16);
  border: var(--card-border);
  box-shadow: var(--sh-sm);
  transition: background var(--t-base), border-color var(--t-base);
}
.card-hover {
  transition: box-shadow var(--transition), transform var(--transition);
  cursor: pointer;
}
.card-hover:hover {
  box-shadow: var(--sh-lg);
  transform: translateY(-2px);
}

/* ── Badges ──────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--rf);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  background: var(--surface-2);
  color: var(--ink-2);
}
.badge-green  { background: #DCFCE7; color: #15803D; }
.badge-yellow { background: #FEF9C3; color: #92400E; }
.badge-amber  { background: #FEF9C3; color: #92400E; }
.badge-red    { background: #FEE2E2; color: #B91C1C; }
.badge-blue   { background: #DBEAFE; color: #1D4ED8; }
.badge-orange { background: var(--pl); color: var(--ph); }
.badge-gray   { background: var(--surface-2); color: var(--ink-3); }

/* dark-mode badge overrides */
[data-mode="dark"] .badge-green  { background: color-mix(in oklch, var(--green) 16%, transparent); color: var(--green); }
[data-mode="dark"] .badge-yellow,
[data-mode="dark"] .badge-amber  { background: color-mix(in oklch, var(--amber) 16%, transparent); color: var(--amber); }
[data-mode="dark"] .badge-red    { background: color-mix(in oklch, var(--red)   16%, transparent); color: var(--red); }
[data-mode="dark"] .badge-blue   { background: color-mix(in oklch, var(--blue)  16%, transparent); color: var(--blue); }

/* ── Avatars ─────────────────────────────────────────────────────────── */
.avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  overflow: hidden;
  background: var(--line-2);
}
.avatar-xs { width: 28px; height: 28px; font-size: 11px; }
.avatar-sm { width: 36px; height: 36px; font-size: 13px; }
.avatar-md { width: 44px; height: 44px; font-size: 15px; }
.avatar-lg { width: 56px; height: 56px; font-size: 18px; }
.avatar-xl { width: 72px; height: 72px; font-size: 22px; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ── Divisor ─────────────────────────────────────────────────────────── */
.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink-4);
  font-size: 13px;
}
.divider::before, .divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}

/* ── Loading spinner ─────────────────────────────────────────────────── */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--line-2);
  border-top-color: var(--p);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}
.spinner-sm { width: 14px; height: 14px; }
.spinner-lg { width: 32px; height: 32px; border-width: 3px; }

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Info box ─────────────────────────────────────────────────────────── */
.info-box {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r10);
  padding: 14px 16px;
  font-size: 13px;
  color: var(--ink-2);
}
.info-box.info-primary {
  background: var(--pb);
  border-color: var(--pl);
  color: var(--ph);
}
.info-box.info-warning {
  background: color-mix(in oklch, var(--amber) 10%, transparent);
  border-color: color-mix(in oklch, var(--amber) 30%, transparent);
  color: var(--amber);
}
.info-box.info-success {
  background: color-mix(in oklch, var(--green) 10%, transparent);
  border-color: color-mix(in oklch, var(--green) 30%, transparent);
  color: var(--green);
}
.info-box.info-error {
  background: color-mix(in oklch, var(--red) 10%, transparent);
  border-color: color-mix(in oklch, var(--red) 30%, transparent);
  color: var(--red);
}

/* ── Tabs ─────────────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--line);
  gap: 0;
}
.tab {
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-3);
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition);
  white-space: nowrap;
  touch-action: manipulation;
}
.tab.active {
  color: var(--p);
  border-bottom-color: var(--p);
  font-weight: 600;
}
.tab:hover:not(.active) { color: var(--ink-2); }
