/* Reusable components: buttons, fields, chips, cards, modals, toggles. */

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--control-h);
  padding: 0 18px;
  border-radius: var(--radius-sm);
  font-size: var(--fs-md); font-weight: 500;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  transition: background .15s, transform .1s, opacity .15s;
}
.btn:active { transform: scale(.985); }
.btn--primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.btn--primary:hover { background: var(--primary-hover); }
.btn--primary:disabled, .btn--primary[aria-disabled="true"] { background: var(--primary-disabled); border-color: var(--primary-disabled); }
.btn--soft { background: var(--green-50); border-color: var(--green-50); color: var(--primary); }
.btn--danger { background: var(--danger-bg); border-color: var(--danger-bg); color: var(--danger); }
.btn--ghost { border-color: transparent; background: transparent; }
.btn--block { display: flex; width: 100%; }
.btn--lg { min-height: 46px; font-size: var(--fs-base); }
.btn:disabled { cursor: default; }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* Sign in with Apple. The logo files are Apple's, height-matched to the button, uncropped.
   Black on light backgrounds; white (black glyph) in dark mode. Title uses the system font. */
.btn.btn--apple {
  --apple-h: 46px;
  min-height: var(--apple-h);
  height: var(--apple-h);
  padding: 0 12px 0 0;
  gap: 0;
  justify-content: center;
  background: #000;
  color: #fff;
  border: 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  font-size: 17px;
  font-weight: 500;
  letter-spacing: -0.022em;
  line-height: 1;
}
.btn.btn--apple:hover, .btn.btn--apple:disabled { background: #000; color: #fff; }
.btn.btn--apple:disabled { opacity: .55; }
.btn-apple__logo { height: 100%; width: auto; flex: none; display: block; pointer-events: none; }
.btn-apple__logo--black { display: none; }
.btn-apple__label { white-space: nowrap; }
:root[data-theme="dark"] .btn.btn--apple,
:root[data-theme="dark"] .btn.btn--apple:hover,
:root[data-theme="dark"] .btn.btn--apple:disabled { background: #fff; color: #000; }
:root[data-theme="dark"] .btn-apple__logo--white { display: none; }
:root[data-theme="dark"] .btn-apple__logo--black { display: block; }

.icon-btn {
  width: var(--hit); height: var(--hit);
  display: grid; place-items: center;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink);
}
.icon-btn--primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.icon-btn--round { border-radius: 50%; }
.icon-btn--plain { border: 0; background: transparent; width: var(--hit); height: var(--hit); }

.back { display: inline-flex; align-items: center; gap: 6px; min-height: var(--hit); padding: 8px 8px 8px 0; font-size: 16px; font-weight: 500; color: var(--ink-soft); }

/* Fields */
.field { display: block; }
.field > .label { margin-bottom: 8px; }
.field > .hint { margin-top: 6px; }
.input, .select, .textarea {
  width: 100%;
  min-height: 46px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: var(--fs-input);
  color: var(--ink);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.textarea { padding: 12px 14px; min-height: 88px; resize: vertical; }
.input::placeholder, .textarea::placeholder { color: var(--placeholder); }
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--green-50); }
.select {
  appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23152438' 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;
}
.input--date { padding-right: 10px; }
.input-prefix { position: relative; }
.input-prefix > span { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: var(--fs-base); }
.input-prefix > .input { padding-left: 42px; }

.search {
  position: relative;
  display: flex; align-items: center;
}
.search > .icon { position: absolute; left: 14px; color: var(--muted); pointer-events: none; }
.search > .input { padding-left: 40px; }
.search > .search__go { position: absolute; right: 12px; color: var(--muted); }
.search--muted > .input { background: var(--surface-muted); border-color: var(--surface-muted); }
.search-row { display: flex; gap: 8px; }
.search-row > .input { flex: 1; }
.search-row > .icon-btn { width: 44px; height: 44px; background: var(--green-50); border-color: var(--green-50); color: var(--primary); }

/* Chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips--scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 calc(var(--gutter) * -1); padding: 0 var(--gutter); }
.chips--scroll::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  flex: none;
  min-height: var(--hit);
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 13px; font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
}
.chip--square { border-radius: var(--radius-sm); min-height: var(--hit); }
.chip > button { width: var(--hit); height: var(--hit); margin-right: -8px; display: inline-grid; place-items: center; flex: none; }
.chip[aria-pressed="true"], .chip--active { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.chip__count { opacity: .8; font-weight: 400; }
.tag {
  display: inline-flex; align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--green-100);
  color: var(--primary);
  font-size: var(--fs-xs); font-weight: 600;
}
.tag--light { background: var(--surface); color: var(--ink); font-weight: 500; }

/* Option tiles (styles, pace, place types) */
.option {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--hit);
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: var(--fs-sm); color: var(--ink);
}
.option--tall { flex-direction: column; min-height: 62px; gap: 6px; font-size: var(--fs-xs); }
.option--xl { flex-direction: column; min-height: 74px; gap: 8px; font-size: var(--fs-xs); }
.option[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}
.card--pad { padding: 16px; }
.card--soft { background: var(--green-50); border-color: var(--green-50); }
.card--muted { background: var(--green-100); border-color: var(--green-100); }
.note {
  display: flex; gap: 10px;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--green-50);
  font-size: var(--fs-xs); color: var(--ink-soft); line-height: 1.55;
}
.note .icon { color: var(--primary); margin-top: 1px; }

/* List rows (profile menu, languages, currencies) */
.list { border-top: 1px solid var(--line); }
.list-row {
  display: flex; align-items: center; gap: 14px;
  width: 100%;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  text-align: left;
}
.list-row__body { flex: 1; min-width: 0; }
.list-row__title { font-size: var(--fs-md); font-weight: 500; color: var(--ink); }
.list-row__sub { font-size: var(--fs-xs); color: var(--muted); margin-top: 2px; }
.list-row > .icon:last-child { color: var(--muted); }

/* Radio dot */
.radio {
  width: 16px; height: 16px; flex: none;
  border-radius: 50%;
  border: 1.5px solid var(--line-strong);
  display: grid; place-items: center;
}
[aria-checked="true"] > .radio, .radio--on { border-color: var(--primary); }
[aria-checked="true"] > .radio::after, .radio--on::after { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--primary); }

/* Toggle */
.toggle { position: relative; display: inline-block; width: 51px; height: var(--hit); flex: none; }
.toggle input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; z-index: 1; }
.toggle span { position: absolute; left: 0; right: 0; top: 6.5px; height: 31px; border-radius: 999px; background: var(--line-strong); transition: background .2s; }
.toggle span::after { content: ''; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform .2s var(--ease); }
.toggle input:checked + span { background: var(--primary); }
.toggle input:checked + span::after { transform: translateX(20px); }

/* Checkbox tiles */
.check {
  display: flex; align-items: center; gap: 10px;
  min-height: var(--hit); padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: var(--fs-sm);
  cursor: pointer;
}
.check input { appearance: none; width: 18px; height: 18px; margin: 0; border: 1.5px solid var(--line-strong); border-radius: 4px; display: grid; place-items: center; flex: none; }
.check input:checked { background: var(--primary); border-color: var(--primary); }
.check input:checked::after { content: ''; width: 5px; height: 9px; border: solid #fff; border-width: 0 2px 2px 0; transform: translateY(-1px) rotate(45deg); }

/* Stepper (- 2 +) */
.counter { display: inline-flex; align-items: center; gap: 8px; padding: 4px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.counter button { width: var(--hit); height: var(--hit); border-radius: 50%; background: var(--green-50); color: var(--primary); display: grid; place-items: center; }
.counter output { min-width: 18px; text-align: center; font-size: 18px; color: var(--ink); }

/* Segmented control */
.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; border-radius: var(--radius); background: var(--surface-muted); }
.segmented button { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--hit); border-radius: 7px; font-size: 13px; color: var(--ink-soft); }
.segmented button[aria-pressed="true"] { background: var(--surface); box-shadow: var(--shadow-card); color: var(--ink); }

/* Wizard progress: "Etapa anterior ━━━━ 2 de 7" */
.progress { display: flex; align-items: center; gap: 14px; margin: 6px 0 26px; }
.progress__bars { flex: 1; display: flex; gap: 6px; justify-content: center; }
.progress__bars i { width: 20px; height: 2px; border-radius: 2px; background: var(--line); }
.progress__bars i.on { background: var(--ink); }
.progress__count { font-size: 10px; color: var(--muted); }

/* Numbered steps inside modals */
.steps { display: flex; gap: 14px; margin: 14px 0 22px; }
.steps__item { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-xs); color: var(--muted); }
.steps__item b { width: 20px; height: 20px; border-radius: 50%; border: 1px solid var(--line); display: grid; place-items: center; font-size: 10px; font-weight: 500; }
.steps__item[aria-current="step"] { color: var(--ink); font-weight: 600; }
.steps__item[aria-current="step"] b { border-color: var(--primary); color: var(--ink); }

/* Modal */
.modal-root {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center;
  padding: max(16px, var(--safe-top)) max(16px, var(--safe-right)) max(16px, var(--safe-bottom)) max(16px, var(--safe-left));
}
.modal-root::before { content: ''; position: absolute; inset: 0; background: var(--overlay); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); animation: fade-in .2s ease; }
.modal {
  position: relative;
  width: 100%; max-width: 470px;
  max-height: calc(100dvh - var(--safe-top) - var(--safe-bottom) - 32px);
  overflow-y: auto;
  padding: 24px 22px 22px;
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow-modal);
  animation: modal-in .26s var(--ease);
}
.modal__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.modal__close { color: var(--ink); flex: none; }
.modal__body { margin-top: 10px; }
@keyframes fade-in { from { opacity: 0; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(12px) scale(.98); } }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 16px);
  transform: translate(-50%, 20px);
  max-width: calc(100% - 32px);
  padding: 11px 16px;
  border-radius: var(--radius);
  background: var(--ink); color: var(--bg);
  font-size: var(--fs-sm);
  opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s var(--ease);
  z-index: 60;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* Empty states */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 40px 12px; }
.empty__icon { width: 64px; height: 64px; border-radius: 50%; background: var(--green-50); color: var(--primary); display: grid; place-items: center; margin-bottom: 22px; }
.empty .title { max-width: 320px; }
.empty .lead { max-width: 330px; }
.empty .btn { margin-top: 22px; }

/* Collapsible (details) */
.disclosure > summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-sm); font-weight: 500; color: var(--ink-soft); }
.disclosure > summary::-webkit-details-marker { display: none; }
.disclosure > summary::before { content: '▸'; font-size: 10px; }
.disclosure[open] > summary::before { content: '▾'; }
