/* Campos mobile usam pelo menos 16px para evitar zoom automático ao receber foco. */
/* Installed PWAs can apply browser text autosizing differently from their tab.
   Keep standalone typography on the same design tokens as the browser UI. */
html.is-standalone-app {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html.is-standalone-app body :is(input, select, textarea):not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="hidden"]):not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="image"]):not([type="file"]) {
  font-family: var(--looply-font-family) !important;
  font-size: var(--text-field) !important;
  font-weight: var(--looply-font-weight-regular) !important;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  box-sizing: border-box !important;
  min-height: var(--looply-field-height) !important;
  height: var(--looply-field-height) !important;
  max-height: var(--looply-field-height) !important;
  line-height: 1.2 !important;
}

html.is-standalone-app body :is(input, textarea)::placeholder {
  font-family: var(--looply-font-family) !important;
  font-size: var(--text-field) !important;
  font-weight: var(--looply-font-weight-regular) !important;
}

html.is-standalone-app body select {
  font-family: var(--looply-font-family) !important;
  font-size: var(--text-field) !important;
  font-weight: var(--looply-font-weight-regular) !important;
}

/* A partir de 16px, o Safari não amplia a página ao focar os campos. */
@media (max-width: 760px), (pointer: coarse) {
  :root body:not(.portal-body) {
    --looply-field-font-size: var(--looply-type-16);
    --text-field: var(--looply-field-font-size);
  }

  :root body:not(.portal-body) :is(input, select, textarea):not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="hidden"]):not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="image"]):not([type="file"]) {
    font-size: var(--text-field) !important;
    -webkit-text-size-adjust: 100% !important;
    text-size-adjust: 100% !important;
  }

  :root body:not(.portal-body) :is(input, textarea)::placeholder {
    font-size: var(--looply-type-16) !important;
    -webkit-text-size-adjust: 100% !important;
    text-size-adjust: 100% !important;
  }

  :root body:not(.portal-body) select option {
    font-size: var(--looply-type-16) !important;
    -webkit-text-size-adjust: 100% !important;
    text-size-adjust: 100% !important;
  }
}

/* Mantém o ajuste de texto do iOS disponível; com campos a 16px o foco não amplia a página. */
@supports (-webkit-touch-callout: none) {
  @media (max-width: 760px), (pointer: coarse) {
    html.is-standalone-app {
      -webkit-text-size-adjust: auto !important;
      text-size-adjust: auto !important;
    }

    :root body:not(.portal-body) :is(input, select, textarea):not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="hidden"]):not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="image"]):not([type="file"]),
    :root body:not(.portal-body) :is(input, textarea)::placeholder,
    :root body:not(.portal-body) select option {
      -webkit-text-size-adjust: 100% !important;
      text-size-adjust: 100% !important;
    }

    :root body:not(.portal-body) .banner-editor-dialog .banner-date-fields input[type="datetime-local"] {
      font-size: var(--text-field) !important;
    }
  }
}

/* Campos editáveis: texto digitado, valor selecionado e placeholder usam a mesma escala no mobile. */
@media (max-width: 760px), (pointer: coarse) {
  :root body:not(.portal-body) :is(input, select, textarea):not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="hidden"]):not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="image"]):not([type="file"]),
  :root body:not(.portal-body) select option,
  :root body:not(.portal-body) input[type="date"]::-webkit-datetime-edit,
  :root body:not(.portal-body) input[type="time"]::-webkit-datetime-edit,
  :root body:not(.portal-body) input[type="datetime-local"]::-webkit-datetime-edit {
    font-size: var(--looply-type-16) !important;
    -webkit-text-size-adjust: 100% !important;
    text-size-adjust: 100% !important;
  }

  :root body:not(.portal-body) :is(input, textarea)::placeholder {
    font-size: var(--looply-type-16) !important;
    -webkit-text-size-adjust: 100% !important;
    text-size-adjust: 100% !important;
  }
}

/* Keep the 48px content row and preserve the device safe area above it. */
@media (max-width: 1024px) {
  .app-shell .main-content > .top-controls {
    box-sizing: border-box !important;
    height: calc(48px + env(safe-area-inset-top, 0px)) !important;
    min-height: calc(48px + env(safe-area-inset-top, 0px)) !important;
    max-height: calc(48px + env(safe-area-inset-top, 0px)) !important;
    flex: 0 0 auto !important;
    padding-top: env(safe-area-inset-top, 0px) !important;
    padding-bottom: 0 !important;
    align-items: center !important;
  }
}

@media (max-width: 760px) {
  :root body:not(.portal-body) h1,
  :root body:not(.portal-body) h2,
  :root body:not(.portal-body) h3 {
    font-size: 16px !important;
    line-height: 24px !important;
  }

  :root body:not(.portal-body) .top-controls #appbarTitle {
    font-size: 16px !important;
    line-height: 24px !important;
  }

  :root body:not(.portal-body) p,
  :root body:not(.portal-body) .description,
  :root body:not(.portal-body) .subtitle,
  :root body:not(.portal-body) .helper-text,
  :root body:not(.portal-body) .support-faq-answer-inner {
    font-size: 12px !important;
    line-height: 16px !important;
  }

  :root body:not(.portal-body) #onboardingWelcomeTitle {
    font-size: 16px !important;
    line-height: 24px !important;
  }

  #homeMetricsGrid .home-summary-value {
    font-size: 20px !important;
    line-height: 24px !important;
  }

  #homeMetricsGrid .home-summary-heading,
  #homeMetricsGrid .home-summary-label,
  #homeMetricsGrid .home-summary-period,
  .support-faq-item summary {
    font-size: 12px !important;
    line-height: 16px !important;
  }

  .onboarding-welcome-skip,
  .onboarding-welcome-start {
    font-size: 14px !important;
  }

  .agenda-time-block > strong {
    font-size: var(--text-action) !important;
  }

  .agenda-appointment-card > strong,
  .agenda-month-chip-title,
  .agenda-month-chip-time {
    font-size: var(--text-caption) !important;
  }
}

/* Campos de formulários em modais não precisam do tamanho ampliado usado
   fora deles no mobile. Mantém valor e placeholder compactos e consistentes. */
@media (max-width: 760px), (pointer: coarse) {
  :root body:not(.portal-body) .modal :is(input, select, textarea):not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="hidden"]):not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="image"]):not([type="file"]),
  :root body:not(.portal-body) .modal select option,
  :root body:not(.portal-body) .modal input[type="date"]::-webkit-datetime-edit,
  :root body:not(.portal-body) .modal input[type="time"]::-webkit-datetime-edit,
  :root body:not(.portal-body) .modal input[type="datetime-local"]::-webkit-datetime-edit {
    font-size: var(--looply-type-14) !important;
    line-height: 1.35 !important;
  }

  :root body:not(.portal-body) .modal :is(input, textarea)::placeholder {
    font-size: var(--looply-type-14) !important;
    line-height: 1.35 !important;
  }
}

/* Formulários longos de configuração e autenticação seguem a escala compacta
   do design system sem alterar os demais campos mobile da plataforma. */
@media (max-width: 760px), (pointer: coarse) {
  :root body:not(.portal-body) :is(.booking-page-form, .auth-form) :is(input, select, textarea):not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="hidden"]):not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="image"]):not([type="file"]) {
    font-size: var(--looply-type-14) !important;
    line-height: 1.35 !important;
  }

  :root body:not(.portal-body) :is(.booking-page-form, .auth-form) :is(input, textarea)::placeholder {
    font-size: var(--looply-type-14) !important;
  }
}

@media (max-width: 1024px) {
  #dashboard :is(.agenda-professional-heading strong, .agenda-column-title, .agenda-week-day, .agenda-week-day-date, .agenda-week-day-initial, .agenda-month-weekdays span, .agenda-month-day) {
    font-size: var(--looply-type-12) !important;
    line-height: 16px !important;
  }

  #dashboard :is(.agenda-time-block, .agenda-appointment-card) > strong,
  #dashboard .agenda-month-chip-title {
    font-weight: 600 !important;
  }

  #dashboard :is(.agenda-time-block, .agenda-appointment-card) > small {
    font-weight: 400 !important;
  }

  #dashboard :is(.agenda-time-block, .agenda-appointment-card) > span,
  #dashboard .agenda-month-chip-time {
    font-weight: 500 !important;
  }
}

/* No agendamento interno, seletores e data seguem o tamanho compacto do campo Horário.
   Campos onde se digita continuam em 16px para evitar zoom automático no iOS. */
@media (max-width: 760px), (pointer: coarse) {
  #appointmentForm select,
  #appointmentForm select option,
  #appointmentForm #appointmentDate,
  #appointmentForm #appointmentNativeDate,
  #appointmentForm #appointmentNativeDate::-webkit-datetime-edit {
    font-size: var(--looply-type-12) !important;
  }
}
