*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --color-primary: #1a4fd6;
  --color-primary-dark: #1340b0;
  --color-bg: #f0f4ff;
  --color-surface: #ffffff;
  --color-text: #0f1c2e;
  --color-muted: #5a6a80;
  --color-border: #dde3ef;
  --color-error: #c0392b;
  --color-error-bg: #fef2f2;
  --color-success: #065f46;
  --color-success-bg: #d1fae5;
  --radius: 12px;
  --font: 'Segoe UI', system-ui, sans-serif;
}

body {
  font-family: var(--font);
  background: var(--color-bg);
  color: var(--color-text);
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 2rem 1rem 4rem;
}

/* --- LAYOUT --- */
.auth-layout {
  width: 100%;
  max-width: 540px;
}

.auth-brand {
  text-align: center;
  margin-bottom: 1.8rem;
}
.auth-brand__logo {
  font-size: 1.8rem;
  font-weight: 900;
  color: var(--color-primary);
  text-decoration: none;
  letter-spacing: -.5px;
}
.auth-brand__tagline {
  font-size: .82rem;
  color: var(--color-muted);
  margin-top: .3rem;
}

/* --- CARD --- */
.auth-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 2.5rem 2.5rem 2rem;
  box-shadow: 0 4px 32px rgba(26,79,214,.08);
}

.auth-card__title {
  font-size: 1.6rem;
  font-weight: 800;
  margin-bottom: .4rem;
}
.auth-card__sub {
  font-size: .92rem;
  color: var(--color-muted);
  margin-bottom: 2rem;
}

/* --- FIELDSET / SECTION --- */
.form-section {
  border: none;
  padding: 0;
  margin-bottom: 1.8rem;
}
.form-section__legend {
  font-size: .78rem;
  font-weight: 700;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: .6px;
  margin-bottom: 1.1rem;
  display: block;
  width: 100%;
  border-bottom: 1px solid var(--color-border);
  padding-bottom: .5rem;
}

/* --- FORM GROUP --- */
.form-group {
  margin-bottom: 1.2rem;
}
.form-group label {
  display: block;
  font-size: .88rem;
  font-weight: 600;
  margin-bottom: .4rem;
}

input[type="text"],
input[type="email"],
input[type="password"] {
  width: 100%;
  padding: .7rem 1rem;
  border: 1.5px solid var(--color-border);
  border-radius: 8px;
  font-size: .95rem;
  font-family: var(--font);
  color: var(--color-text);
  background: var(--color-surface);
  transition: border-color .2s, box-shadow .2s;
  outline: none;
}

input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(26,79,214,.12);
}

input.input--error {
  border-color: var(--color-error);
}

/* --- EYE VIEWER (password toggle) --- */
.input-password {
  position: relative;
}
.input-password input {
  padding-right: 3rem;
}

.eye-viewer {
  position: absolute;
  top: 50%;
  right: .8rem;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-muted);
  padding: .2rem;
  display: flex;
  align-items: center;
  transition: color .2s;
}
.eye-viewer:hover { color: var(--color-primary); }
.eye-viewer:focus-visible {
  outline: 2px solid var(--color-primary);
  border-radius: 4px;
}

.eye-icon { width: 20px; height: 20px; }

/* Toggle state */
.eye-icon--closed { display: none; }
.eye-viewer[aria-pressed="true"] .eye-icon--open { display: none; }
.eye-viewer[aria-pressed="true"] .eye-icon--closed { display: block; }

/* --- FORM ERRORS --- */
.form-error {
  display: block;
  font-size: .8rem;
  color: var(--color-error);
  margin-top: .3rem;
  min-height: 1rem;
}

/* --- CHECKBOX / RGPD --- */
.form-group--checkbox {
  margin-bottom: 1.6rem;
}
.checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: .7rem;
  font-size: .88rem;
  line-height: 1.5;
  cursor: pointer;
}
.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  margin-top: .1rem;
  accent-color: var(--color-primary);
  cursor: pointer;
}
.checkbox-label a { color: var(--color-primary); }

/* Consentimiento opcional (marketing) — visualmente distinto del RGPD obligatorio */
.checkbox-label--optional {
  color: var(--color-text-muted, #6b7280);
  font-size: .82rem;
}
.checkbox-label--optional em {
  font-style: normal;
  color: var(--color-text-muted, #6b7280);
  opacity: .8;
}

/* --- API FEEDBACK --- */
.api-error {
  background: var(--color-error-bg);
  border: 1px solid var(--color-error);
  border-radius: 8px;
  padding: .8rem 1rem;
  font-size: .88rem;
  color: var(--color-error);
  margin-bottom: 1.2rem;
}
.api-success {
  background: var(--color-success-bg);
  border: 1px solid var(--color-success);
  border-radius: 8px;
  padding: .8rem 1rem;
  font-size: .88rem;
  color: var(--color-success);
  margin-bottom: 1.2rem;
}

/* --- SUBMIT BUTTON --- */
.btn-submit {
  width: 100%;
  padding: .85rem 1rem;
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background .2s, transform .15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .6rem;
  margin-bottom: 1.4rem;
}
.btn-submit:hover:not(:disabled) { background: var(--color-primary-dark); transform: translateY(-1px); }
.btn-submit:disabled { opacity: .6; cursor: not-allowed; transform: none; }

/* Spinner */
.btn-submit__spinner {
  display: none;
  width: 18px;
  height: 18px;
  border: 2.5px solid rgba(255,255,255,.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
.btn-submit.loading .btn-submit__spinner { display: block; }
.btn-submit.loading .btn-submit__text { opacity: .75; }

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

/* --- FOOTER LINK --- */
.auth-footer {
  text-align: center;
  font-size: .88rem;
  color: var(--color-muted);
}
.auth-footer a { color: var(--color-primary); font-weight: 600; text-decoration: none; }
.auth-footer a:hover { text-decoration: underline; }

@media (max-width: 560px) {
  .auth-card { padding: 1.8rem 1.2rem; }
}
