/* === 01. Reset, Tipografía y Base === */

* {
  box-sizing: border-box;
}

html {
  background: var(--color-bg-app);
  scroll-padding-bottom: calc(150px + env(safe-area-inset-bottom, 0px));
}

html,
body,
input,
button,
select,
textarea {
  font-family: 'Poppins', system-ui, sans-serif;
}

body {
  min-width: 320px;
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background: var(--color-bg-app);
  font-size: 14px;
  line-height: 1.45;
  scroll-padding-bottom: calc(150px + env(safe-area-inset-bottom, 0px));
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  cursor: pointer;
}

a,
button,
input,
select,
textarea,
[tabindex] {
  scroll-margin-bottom: calc(150px + env(safe-area-inset-bottom, 0px));
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1,
h2,
h3 {
  color: var(--primary);
}

.material-symbols-outlined {
  font-family: 'Material Symbols Outlined';
  font-weight: 400;
  font-style: normal;
  font-size: 24px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  font-feature-settings: 'liga';
}

/* === 02. Estructura de Aplicación y Navegación === */

.app-shell {
  position: relative;
  width: min(100%, 480px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: 24px 24px calc(150px + env(safe-area-inset-bottom, 0px));
  overflow: hidden;
  background: var(--color-bg-app);
  box-shadow: 0 0 26px rgba(51, 25, 86, 0.08);
}

.section-shell {
  padding-top: 24px;
}

.section-intro {
  margin: 8px 0 30px;
}

.section-intro h1,
.section-intro h2 {
  margin: 0;
  font-size: 30px;
  line-height: 38px;
  letter-spacing: -0.02em;
}

.section-intro p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 24px;
}

.page-header {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  height: 64px;
  margin: -24px -24px 24px;
  padding: 0 14px;
  background: var(--white);
  box-shadow: 0 4px 20px rgba(74, 48, 109, 0.035);
}

.page-header h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  line-height: 32px;
  text-align: center;
}

.page-header__back {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  color: var(--primary);
}

.page-header__spacer {
  width: 44px;
}

.bottom-nav {
  position: fixed;
  z-index: 30;
  left: 50%;
  bottom: 0;
  display: flex;
  width: min(100%, 480px);
  min-height: 78px;
  justify-content: space-around;
  align-items: center;
  padding: 8px 12px calc(10px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  border-radius: 20px 20px 0 0;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 -4px 20px rgba(74, 48, 109, 0.08);
  backdrop-filter: blur(14px);
}

.nav-item {
  display: flex;
  flex: 1;
  min-width: 0;
  min-height: 48px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 4px 2px;
  border-radius: var(--radius-btn);
  color: var(--muted);
  font-size: 13px;
  line-height: 14px;
}

.nav-item > .material-symbols-outlined {
  font-size: 24px;
}

.nav-item--active {
  background: var(--aurora-lavender);
  color: var(--color-primary);
}

.nav-item--active > .material-symbols-outlined {
  font-variation-settings: 'FILL' 1;
}

/* === 03. Botones y Controles de Formulario === */

.button {
  display: inline-flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 18px;
  border: 0;
  border-radius: var(--radius-btn);
  font-weight: 500;
  transition: background 0.2s, opacity 0.2s;
}

.button--primary {
  background: var(--primary);
  color: #fff;
}

.button--secondary {
  background: var(--soft);
  color: var(--ink);
}

.button--secondary:hover {
  background: var(--line);
}

.button--danger {
  background: var(--aurora-error-bg);
  color: #93000a;
}

.button--danger:hover {
  background: #ffb4ab;
}

.button--ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 12px 20px;
  border-radius: 12px;
  background: #FFFFFF;
  border: 1px solid var(--aurora-divider);
  color: #5C5364;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  text-align: center;
  transition: all 0.15s ease;
}

.button--ghost:hover {
  background: var(--aurora-surface-soft);
  color: #6C4BA3;
  border-color: rgba(108, 75, 163, 0.38);
}

.button--ghost:active {
  transform: scale(0.98);
}

.button--wide {
  width: 100%;
}

.icon-button {
  display: grid;
  width: 44px;
  height: 44px;
  margin: 0;
  padding: 0;
  place-items: center;
  border: 0;
  background: transparent;
  color: var(--muted);
}

form label {
  display: block;
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

input,
select,
textarea,
.form-control {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 12px;
  border: var(--border-input);
  border-radius: var(--radius-btn);
  background: var(--color-surface);
  color: var(--ink);
  font: inherit;
  transition: border-color 0.2s, background-color 0.2s;
}

textarea,
textarea.form-control {
  min-height: 88px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus,
.form-control:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-color: var(--primary-light);
}

a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.form-note {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin: 16px 0 0;
  color: #6b6570;
  font-size: 13px;
}

.form-note .material-symbols-outlined {
  font-size: 14px;
}

.stack-form {
  margin-top: 18px;
}

.stack-form fieldset {
  margin: 18px 0;
  padding: 0;
  border: 0;
}

.stack-form legend {
  margin-bottom: 10px;
  color: var(--primary);
  font-size: 15px;
  font-weight: 600;
}

.form-help {
  color: var(--muted);
  font-size: 14px;
}

.form-error {
  margin: 8px 0 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--aurora-error-bg);
  color: #93000a;
  font-size: 13px;
  font-weight: 500;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.checkbox-row input {
  width: auto;
  margin: 0;
}

.form-control-types {
  border: 0;
  padding: 0;
  margin: 0;
}

.form-label-with-link {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

/* === 04. Utilidades Visuales, Accesibilidad y Páginas de Error === */

.eyebrow {
  margin: 0;
  color: var(--secondary);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.05em;
}

.muted-row {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
}

.muted-row .material-symbols-outlined {
  font-size: 18px;
  flex: 0 0 auto;
}

.progress-track {
  width: 100%;
  height: 8px;
  overflow: hidden;
  border-radius: 99px;
  background: var(--line);
}

.progress-track > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--pink-strong), var(--secondary));
}

.divider {
  height: 1px;
  margin: 16px 0 0;
  background: var(--line);
}

.skip-link {
  position: absolute;
  z-index: 100;
  top: -48px;
  left: 12px;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
}

.skip-link:focus {
  top: 12px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.text-large {
  font-size: 16px;
}

.text-large h1 {
  font-size: 31px;
}

.text-large h2 {
  font-size: 26px;
}

.text-large .profile-card,
.text-large .settings-action-row,
.text-large p,
.text-large label,
.text-large input,
.text-large button {
  font-size: 1.15em !important;
}

.consent-notice {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  margin: 0 0 20px;
  border-radius: 12px;
  background: #FFFFFF;
  border: 1px solid rgba(108, 75, 163, 0.12);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.02);
  color: #2D1F3F;
  text-decoration: none;
  min-height: 48px;
  transition: border-color 0.15s, background-color 0.15s;
}

.consent-notice:hover {
  border-color: rgba(108, 75, 163, 0.25);
  background-color: var(--aurora-surface-soft);
}

.consent-notice__icon {
  font-size: 22px;
  color: #6C4BA3;
  flex-shrink: 0;
}

.consent-notice__text {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  color: #2D1F3F;
  line-height: 1.4;
}

.consent-notice__chevron {
  font-size: 20px;
  color: #8b496c;
  flex-shrink: 0;
}

.settings-action-row {
  display: grid;
  grid-template-columns: 24px 1fr auto auto;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 12px 18px;
  width: 100%;
  border: 0;
  background: transparent;
  text-decoration: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  list-style: none;
  transition: background 0.15s;
}

.settings-action-row::-webkit-details-marker {
  display: none;
}

.settings-action-row--clickable:hover {
  background: var(--aurora-surface-soft);
}

.error-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 8px;
}

.error-page__icon {
  font-size: 44px;
  color: var(--primary);
  margin-bottom: 4px;
}

.error-page__retry {
  margin-top: 8px;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, 8px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

@media (max-width: 350px) {
  .app-shell {
    padding-right: 18px;
    padding-left: 18px;
  }

  .page-header {
    margin-right: -18px;
    margin-left: -18px;
  }

  .nav-item {
    min-width: 52px;
    padding-right: 6px;
    padding-left: 6px;
  }
}

@media (min-width: 700px) {
  .app-shell,
  .bottom-nav {
    width: min(100%, 480px);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
