/* ============================================================
   Componentes reutilizáveis
   ============================================================ */

/* ---------- Botões ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0.65rem 1.15rem;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 800;
  line-height: 1.1;
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--duration-fast) var(--ease-out), color var(--duration-fast) var(--ease-out),
    border-color var(--duration-fast) var(--ease-out), transform var(--duration-fast) var(--ease-out),
    box-shadow var(--duration-fast) var(--ease-out);
}

.btn svg { width: 1.15rem; height: 1.15rem; flex: none; }

.btn:active { transform: translateY(1px); }

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.btn--primary {
  background: var(--blush-500);
  color: var(--white);
  box-shadow: 0 8px 20px rgba(184, 67, 106, 0.22);
}

.btn--primary:hover:not(:disabled) {
  background: var(--blush-600);
  box-shadow: 0 10px 24px rgba(184, 67, 106, 0.3);
}

.btn--secondary {
  background: var(--surface);
  color: var(--blush-600);
  border-color: var(--blush-200);
  box-shadow: var(--shadow-sm);
}

.btn--secondary:hover:not(:disabled) { background: var(--blush-50); border-color: var(--blush-300); }

.btn--ghost { color: var(--slate); }
.btn--ghost:hover:not(:disabled) { background: var(--surface-muted); color: var(--ink); }

.btn--soft { background: var(--mint-50); color: var(--success-text); }
.btn--soft:hover:not(:disabled) { background: var(--mint-100); }

.btn--danger { background: var(--alert-text); color: var(--white); }
.btn--danger:hover:not(:disabled) { background: #741f38; }

.btn--sm { min-height: 36px; padding: 0.4rem 0.8rem; font-size: 0.8rem; }
.btn--sm svg { width: 1rem; height: 1rem; }
.btn--lg { min-height: 52px; padding: 0.85rem 1.5rem; font-size: 1rem; }
.btn--block { width: 100%; }

.btn--icon {
  width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  border-radius: 50%;
  background: var(--surface);
  border-color: var(--line);
  color: var(--slate);
  box-shadow: var(--shadow-sm);
}

.btn--icon:hover:not(:disabled) { color: var(--blush-600); border-color: var(--blush-200); background: var(--blush-50); }
.btn--icon svg { width: 1.2rem; height: 1.2rem; }
.btn--icon.btn--sm { width: 36px; height: 36px; min-height: 36px; }

.btn.is-loading { color: transparent !important; pointer-events: none; position: relative; }
.btn.is-loading::after {
  content: "";
  position: absolute;
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-top-color: var(--white);
  animation: spin 0.7s linear infinite;
}
.btn--secondary.is-loading::after,
.btn--ghost.is-loading::after { border-color: var(--blush-200); border-top-color: var(--blush-600); }

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

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 50%;
  background: transparent;
  color: var(--slate);
  transition: background var(--duration-fast), color var(--duration-fast);
}
.icon-btn:hover { background: var(--surface-muted); color: var(--ink); }
.icon-btn svg { width: 1.2rem; height: 1.2rem; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.card--pad { padding: var(--space-5); }
.card--soft { background: linear-gradient(160deg, var(--surface), var(--surface-soft)); }
.card--tint { background: linear-gradient(160deg, var(--blush-50), var(--surface) 60%); }

.card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-5) 0;
}

.card__title { font-size: var(--text-h3); }
.card__subtitle { margin-top: 0.15rem; font-size: var(--text-xs); color: var(--slate); }
.card__body { padding: var(--space-4) var(--space-5) var(--space-5); }

/* ---------- Badges e chips ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-pill);
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1.4;
  white-space: nowrap;
}

.badge svg { width: 0.85rem; height: 0.85rem; }
.badge--mint { background: var(--mint-100); color: var(--success-text); }
.badge--butter { background: var(--warning-bg); color: var(--warning-text); }
.badge--alert { background: var(--alert-bg); color: var(--alert-text); }
.badge--sky { background: var(--sky-100); color: var(--info-text); }
.badge--blush { background: var(--blush-100); color: var(--blush-600); }
.badge--lavender { background: var(--lavender-50); color: #5B4A86; }
.badge--neutral { background: var(--surface-muted); color: var(--slate); }
.badge--outline { background: transparent; border: 1px solid var(--line-strong); color: var(--slate); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  min-height: 36px;
  padding: 0.35rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--slate);
  font-size: 0.8rem;
  font-weight: 800;
  white-space: nowrap;
  transition: all var(--duration-fast) var(--ease-out);
}
.chip:hover { border-color: var(--blush-200); color: var(--blush-600); }
.chip.is-active { background: var(--blush-500); border-color: var(--blush-500); color: var(--white); }
.chip.is-active:hover { color: var(--white); }

/* ---------- Segmented control ---------- */
.segmented {
  display: inline-flex;
  gap: 0.2rem;
  padding: 0.25rem;
  border-radius: var(--radius-pill);
  background: var(--surface-muted);
  border: 1px solid var(--line);
}

.segmented__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: 36px;
  padding: 0.35rem 0.85rem;
  border: 0;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--slate);
  font-size: 0.82rem;
  font-weight: 800;
  white-space: nowrap;
  transition: all var(--duration-fast) var(--ease-out);
}
.segmented__btn svg { width: 1rem; height: 1rem; }
.segmented__btn:hover { color: var(--ink); }
.segmented__btn.is-active { background: var(--surface); color: var(--blush-600); box-shadow: var(--shadow-sm); }

/* ---------- Avatar ---------- */
.baby-avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--blush-100), var(--sky-100));
  color: var(--blush-600);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
  border: 2px solid var(--white);
  box-shadow: var(--shadow-sm);
}
.baby-avatar--sm { width: 2.25rem; height: 2.25rem; font-size: 0.9rem; }
.baby-avatar--lg { width: 4.25rem; height: 4.25rem; font-size: 1.6rem; }

/* ---------- Formulários ---------- */
.field { display: flex; flex-direction: column; gap: 0.35rem; min-width: 0; }
.field__label { font-size: 0.82rem; font-weight: 800; color: var(--ink); }
.field__label .optional { color: var(--slate-soft); font-weight: 600; }
.field__hint { font-size: var(--text-xs); color: var(--slate); line-height: 1.45; }
.field__error { display: flex; align-items: flex-start; gap: 0.3rem; font-size: var(--text-xs); color: var(--alert-text); font-weight: 700; }
.field__error svg { width: 0.9rem; height: 0.9rem; flex: none; margin-top: 0.1rem; }

.input,
.select,
.textarea {
  width: 100%;
  min-height: 44px;
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font-size: 1rem;
  font-weight: 600;
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast), background var(--duration-fast);
}

.input::placeholder,
.textarea::placeholder { color: var(--slate-soft); font-weight: 500; }

.input:hover,
.select:hover,
.textarea:hover { border-color: var(--blush-200); }

.input:focus-visible,
.select:focus-visible,
.textarea:focus-visible {
  outline: none;
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(47, 107, 86, 0.14);
}

.input[aria-invalid="true"],
.select[aria-invalid="true"],
.textarea[aria-invalid="true"] {
  border-color: var(--alert-text);
  background: #FFFBFC;
}

.textarea { min-height: 5.5rem; resize: vertical; line-height: 1.5; }
.select { appearance: none; 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='%235C6B77' stroke-width='2.5' 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 0.85rem center; padding-right: 2.4rem; }

.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap .input { padding-right: 3.2rem; }
.input-suffix {
  position: absolute;
  right: 0.9rem;
  font-size: var(--text-xs);
  font-weight: 800;
  color: var(--slate-soft);
  pointer-events: none;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4);
}
.form-grid .field--full { grid-column: 1 / -1; }

@media (max-width: 560px) {
  .form-grid { grid-template-columns: 1fr; }
}

.radio-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-2); }
@media (max-width: 560px) { .radio-cards { grid-template-columns: 1fr; } }

.radio-card { position: relative; display: flex; }
.radio-card input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.radio-card__box {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  width: 100%;
  min-height: 56px;
  justify-content: center;
  padding: 0.6rem 0.85rem;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition: all var(--duration-fast) var(--ease-out);
}
.radio-card__title { font-size: 0.88rem; font-weight: 800; color: var(--ink); }
.radio-card__hint { font-size: var(--text-xs); color: var(--slate); }
.radio-card input:checked + .radio-card__box {
  border-color: var(--blush-500);
  background: var(--blush-50);
  box-shadow: 0 0 0 3px rgba(184, 67, 106, 0.1);
}
.radio-card input:focus-visible + .radio-card__box { outline: 2px solid var(--focus); outline-offset: 2px; }

.checkbox { display: flex; align-items: flex-start; gap: 0.6rem; font-size: var(--text-sm); color: var(--slate); font-weight: 600; }
.checkbox input { width: 1.15rem; height: 1.15rem; margin-top: 0.15rem; accent-color: var(--blush-500); flex: none; }

/* ---------- Tabelas ---------- */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
  min-width: 46rem;
}

.data-table th {
  position: sticky;
  top: 0;
  padding: 0.7rem 0.9rem;
  background: var(--surface-muted);
  color: var(--slate);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
}

.data-table td {
  padding: 0.8rem 0.9rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: 0; }
.data-table tbody tr { transition: background var(--duration-fast); }
.data-table tbody tr:hover { background: var(--surface-soft); }
.data-table .value-cell { font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.data-table .sub-value { display: block; font-size: 0.7rem; font-weight: 700; color: var(--slate); }
.data-table .row-actions { display: flex; gap: 0.15rem; justify-content: flex-end; }

.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--line);
}

.table-empty { padding: var(--space-10) var(--space-5); text-align: center; color: var(--slate); }

/* ---------- Diálogos ---------- */
dialog.dialog {
  width: min(38rem, calc(100vw - 2rem));
  max-height: min(88vh, 54rem);
  padding: 0;
  border: 0;
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

dialog.dialog--wide { width: min(54rem, calc(100vw - 2rem)); }
dialog.dialog::backdrop { background: rgba(51, 63, 72, 0.38); backdrop-filter: blur(3px); }

.dialog__inner { display: flex; flex-direction: column; max-height: min(88vh, 54rem); }

.dialog__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-5) var(--space-3);
}

.dialog__title { font-size: var(--text-h2); }
.dialog__subtitle { margin-top: 0.2rem; font-size: var(--text-sm); color: var(--slate); }

.dialog__body {
  padding: var(--space-2) var(--space-5) var(--space-5);
  overflow-y: auto;
}

.dialog__footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--line);
  background: var(--surface-soft);
  flex-wrap: wrap;
}

.dialog__footer--between { justify-content: space-between; }

@media (max-width: 640px) {
  dialog.dialog {
    width: 100vw;
    max-width: 100vw;
    margin: 0;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    position: fixed;
    inset: auto 0 0 0;
    max-height: 92dvh;
  }
  dialog.dialog[open] { animation: sheet-up var(--duration-base) var(--ease-out); }
  .dialog__inner { max-height: 92dvh; }
  @keyframes sheet-up { from { transform: translateY(24px); opacity: 0.6; } to { transform: none; opacity: 1; } }
}

/* ---------- Toasts ---------- */
.toast {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.8rem 0.95rem;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-md);
  pointer-events: auto;
  animation: toast-in var(--duration-base) var(--ease-out);
}
@keyframes toast-in { from { opacity: 0; transform: translateY(10px) scale(0.98); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .toast { animation: none; } }

.toast__icon {
  display: grid;
  place-items: center;
  width: 1.9rem;
  height: 1.9rem;
  flex: none;
  border-radius: 50%;
}
.toast__icon svg { width: 1.05rem; height: 1.05rem; }
.toast__body { flex: 1; min-width: 0; }
.toast__title { font-size: 0.86rem; font-weight: 800; }
.toast__msg { margin-top: 0.1rem; font-size: var(--text-xs); color: var(--slate); overflow-wrap: anywhere; }
.toast__action {
  border: 0;
  background: transparent;
  color: var(--blush-600);
  font-size: var(--text-xs);
  font-weight: 800;
  padding: 0.3rem 0.2rem;
  min-height: 32px;
}
.toast--success .toast__icon { background: var(--mint-100); color: var(--success-text); }
.toast--error .toast__icon { background: var(--alert-bg); color: var(--alert-text); }
.toast--info .toast__icon { background: var(--sky-100); color: var(--info-text); }
.toast--warning .toast__icon { background: var(--warning-bg); color: var(--warning-text); }

/* ---------- Empty state ---------- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--space-3);
  padding: var(--space-8) var(--space-5);
}
.empty-state__art {
  display: grid;
  place-items: center;
  width: 5.5rem;
  height: 5.5rem;
  border-radius: 2rem;
  background: linear-gradient(145deg, var(--blush-50), var(--sky-50));
  color: var(--blush-500);
  border: 1px solid var(--line);
}
.empty-state__art svg { width: 2.6rem; height: 2.6rem; }
.empty-state__title { font-family: var(--font-display); font-size: 1.1rem; font-weight: 700; }
.empty-state__text { max-width: 28rem; font-size: var(--text-sm); color: var(--slate); }
.empty-state__actions { display: flex; gap: var(--space-2); flex-wrap: wrap; justify-content: center; margin-top: var(--space-1); }

/* ---------- Alertas inline ---------- */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  line-height: 1.5;
}
.alert svg { width: 1.15rem; height: 1.15rem; flex: none; margin-top: 0.15rem; }
.alert__body { min-width: 0; }
.alert__title { font-weight: 800; }
.alert__text { margin-top: 0.1rem; }
.alert--info { background: var(--info-bg); color: var(--info-text); }
.alert--success { background: var(--success-bg); color: var(--success-text); }
.alert--warning { background: var(--warning-bg); color: var(--warning-text); }
.alert--alert { background: var(--alert-bg); color: var(--alert-text); }
.alert--neutral { background: var(--surface-muted); color: var(--slate); }
.alert a { color: inherit; font-weight: 800; }

/* ---------- Disclosure ---------- */
.disclosure { border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); }
.disclosure > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 0.8rem 1rem;
  cursor: pointer;
  font-weight: 800;
  font-size: var(--text-sm);
  color: var(--ink);
  list-style: none;
  border-radius: var(--radius-md);
}
.disclosure > summary::-webkit-details-marker { display: none; }
.disclosure > summary::after {
  content: "";
  width: 0.55rem;
  height: 0.55rem;
  border-right: 2px solid var(--slate);
  border-bottom: 2px solid var(--slate);
  transform: rotate(45deg);
  transition: transform var(--duration-fast);
  flex: none;
  margin-right: 0.2rem;
}
.disclosure[open] > summary::after { transform: rotate(225deg); }
.disclosure__body { padding: 0 1rem 1rem; font-size: var(--text-sm); color: var(--slate); }

/* ---------- Skeletons ---------- */
.skeleton {
  position: relative;
  overflow: hidden;
  background: var(--surface-muted);
  border-radius: var(--radius-sm);
}
.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.75), transparent);
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer { 100% { transform: translateX(100%); } }
.skeleton--title { height: 1.4rem; width: 45%; }
.skeleton--text { height: 0.9rem; width: 70%; }
.skeleton--card { height: 8rem; }

/* ---------- Stepper ---------- */
.stepper {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  list-style: none;
  padding: 0;
  margin: 0;
  flex-wrap: wrap;
}
.stepper__item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: var(--text-xs);
  font-weight: 800;
  color: var(--slate-soft);
}
.stepper__dot {
  display: grid;
  place-items: center;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 50%;
  background: var(--surface-muted);
  border: 1px solid var(--line);
  font-size: 0.7rem;
}
.stepper__item.is-active { color: var(--blush-600); }
.stepper__item.is-active .stepper__dot { background: var(--blush-500); border-color: var(--blush-500); color: var(--white); }
.stepper__item.is-done { color: var(--success-text); }
.stepper__item.is-done .stepper__dot { background: var(--mint-100); border-color: var(--mint-200); color: var(--success-text); }
.stepper__line { width: 1.2rem; height: 1px; background: var(--line-strong); }
@media (max-width: 560px) { .stepper__label { display: none; } .stepper__line { width: 0.75rem; } }

/* ---------- Dropzone ---------- */
.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  width: 100%;
  min-height: 14rem;
  padding: var(--space-8) var(--space-5);
  border: 2px dashed var(--line-strong);
  border-radius: var(--radius-lg);
  background: var(--surface-soft);
  color: var(--slate);
  text-align: center;
  transition: border-color var(--duration-fast), background var(--duration-fast), transform var(--duration-fast);
  cursor: pointer;
}
.dropzone:hover, .dropzone:focus-visible { border-color: var(--blush-300); background: var(--blush-50); outline: none; }
.dropzone.is-dragover { border-color: var(--blush-500); background: var(--blush-50); transform: scale(1.005); }
.dropzone__icon {
  display: grid;
  place-items: center;
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 1.25rem;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  color: var(--blush-500);
}
.dropzone__icon svg { width: 1.6rem; height: 1.6rem; }
.dropzone__title { font-family: var(--font-display); font-size: 1.05rem; font-weight: 700; color: var(--ink); }
.dropzone__hint { font-size: var(--text-xs); color: var(--slate); }

/* ---------- Barra de progresso ---------- */
.progress { width: 100%; height: 0.5rem; border-radius: 999px; background: var(--surface-muted); overflow: hidden; }
.progress__bar { height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--blush-300), var(--blush-500)); transition: width var(--duration-slow) var(--ease-out); }

/* ---------- Divisórias / tags ---------- */
.divider { height: 1px; background: var(--line); border: 0; margin: 0; }
.tag-list { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; }
.section-title h2 { font-size: var(--text-h2); }
.section-title__hint { font-size: var(--text-xs); color: var(--slate); }

/* ---------- Spinner ---------- */
.spinner {
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  border: 2px solid var(--line-strong);
  border-top-color: var(--blush-500);
  animation: spin 0.8s linear infinite;
  flex: none;
}

.loading-line { display: flex; align-items: center; gap: var(--space-3); color: var(--slate); font-size: var(--text-sm); }

/* Grade de três campos (medidas no formulário) */
.form-grid--three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 700px) { .form-grid--three { grid-template-columns: 1fr; } }
