:root {
  --magenta:        #A6195C;
  --magenta-dark:   #7A1244;
  --magenta-soft:   #FCE7F0;
  --ink:            #1E1E24;
  --ink-soft:       #4A4A55;
  --muted:          #8A8A95;
  --line:           #E4E4EA;
  --bg:             #F6F4F2;
  --card:           #FFFFFF;
  --danger:         #C0392B;
  --radius:         12px;
  --radius-lg:      18px;
  --shadow:         0 10px 40px rgba(122, 18, 68, 0.08);
  --shadow-hover:   0 14px 48px rgba(122, 18, 68, 0.18);
  --font:           'Nunito Sans', system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1100px 600px at 110% -10%, var(--magenta-soft), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, #FFE9D9, transparent 55%),
    var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.page {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 48px 20px;
}

/* ------- Card ------- */
.card {
  width: 100%;
  max-width: 720px;
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card__header {
  padding: 28px 40px;
  background: linear-gradient(135deg, var(--magenta) 0%, var(--magenta-dark) 100%);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 20px;
}

.card__logo {
  height: 62px;
  width: auto;
  flex-shrink: 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  opacity: 0.95;
}
.brand__mark {
  width: 32px; height: 32px;
  display: inline-grid;
  place-items: center;
  background: #fff;
  color: var(--magenta);
  border-radius: 8px;
  font-weight: 800;
  font-size: 18px;
}
.brand__name {
  font-weight: 700;
  letter-spacing: 0.5px;
  font-size: 15px;
}

.card__title {
  flex: 1;
  margin: 0;
  text-align: center;
  font-size: 24px;
  line-height: 1.3;
  font-weight: 700;
}
.card__title span { color: #FFD9E6; }

.card__subtitle {
  margin: 0;
  opacity: 0.9;
  font-size: 15px;
}

/* ------- Form ------- */
.form {
  padding: 28px 40px 36px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.form__group {
  border: 0;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form__legend {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--magenta);
  padding: 0;
  margin-bottom: 4px;
  width: 100%;
}

.form__legend::before,
.form__legend::after {
  content: '';
  flex: 1;
  border-top: 2px dotted currentColor;
  opacity: 0.4;
}

.form__legend-icono {
  width: 15px;
  height: 15px;
  stroke-width: 2.2;
  flex-shrink: 0;
}

/* ------- Layout dos columnas (paciente | contacto) ------- */
.form__columnas {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: start;
}

.form__col {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
}

.req { color: var(--magenta); margin-left: 2px; }
.hint { color: var(--muted); font-weight: 500; }

input[type=text],
input[type=email],
input[type=tel],
select,
textarea {
  width: 100%;
  padding: 12px 14px;
  font-size: 15px;
  font-family: inherit;
  color: var(--ink);
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  transition: border-color .15s, box-shadow .15s, background .15s;
}

input::placeholder, textarea::placeholder { color: #B5B5BE; }

input:hover, select:hover, textarea:hover { border-color: #CFCFD8; }

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--magenta);
  box-shadow: 0 0 0 4px rgba(166, 25, 92, 0.12);
}

textarea { resize: vertical; min-height: 96px; }

select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'><path d='M1 1.5L6 6.5L11 1.5' stroke='%23A6195C' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 38px;
}

/* ------- Phone ------- */
.phone {
  display: flex;
  align-items: stretch;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color .15s, box-shadow .15s;
  background: #fff;
}
.phone:focus-within {
  border-color: var(--magenta);
  box-shadow: 0 0 0 4px rgba(166, 25, 92, 0.12);
}
.phone__prefix {
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  background: #FAFAFC;
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 14px;
  border-right: 1.5px solid var(--line);
  white-space: nowrap;
}
.phone input {
  border: 0;
  border-radius: 0;
}
.phone input:focus { box-shadow: none; }

/* ------- File ------- */
.file-field {
  flex-direction: row;
  align-items: center;
  gap: 12px;
}

.file-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border: 1.5px dashed var(--magenta);
  color: var(--magenta);
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 600;
  background: var(--magenta-soft);
  width: max-content;
  transition: background .15s;
}
.file-label:hover { background: #F8D6E3; }

.file-hint {
  flex: 1;
  margin: 0;
  font-size: 13px;
  color: var(--ink-soft);
  background: #FFF7E6;
  border-left: 3px solid #F4B740;
  padding: 8px 12px;
  border-radius: 6px;
  text-align: center;
}

/* ------- Cuidador ------- */
.field--al-pie {
  justify-content: flex-end;
}

/* El checkbox comparte fila con un select: le damos la misma
   apariencia de "caja de input" para que no se vea descolgado */
.field--al-pie .checkbox {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}

.field--al-pie .checkbox:has(input:focus-visible) {
  border-color: var(--magenta);
  box-shadow: 0 0 0 4px rgba(166, 25, 92, 0.12);
}

/* La sección del cuidador vive dentro del fieldset del paciente.
   Por defecto oculta; se muestra como un bloque anidado al marcarla. */
.seccion-cuidador {
  display: none;
  border: 0;
  margin: 0;
  padding: 0;
}

.seccion-cuidador--visible {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
  background: #FFF7FB;
  border-radius: 8px;
  border: 1.5px solid #F0D5E4;
  animation: entrada-suave 0.22s ease;
}

@keyframes entrada-suave {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ------- Consent ------- */
.consent { padding-top: 4px; }

.consent__aviso {
  margin: 10px 0 0;
  padding: 12px 14px;
  border-left: 3px solid var(--magenta);
  background: var(--magenta-soft);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 0.85rem;
  line-height: 1.55;
  color: var(--ink-soft);
}

.consent__aviso strong { color: var(--magenta-dark); font-weight: 700; }

.checkbox {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 14px;
  color: var(--ink-soft);
  cursor: pointer;
  font-weight: 500;
  line-height: 1.5;
}
.checkbox input { position: absolute; opacity: 0; pointer-events: none; }
.checkbox__box {
  flex: 0 0 20px;
  width: 20px; height: 20px;
  border: 1.5px solid var(--line);
  border-radius: 6px;
  background: #fff;
  margin-top: 1px;
  display: inline-grid;
  place-items: center;
  transition: all .15s;
}
.checkbox__box::after {
  content: "";
  width: 10px; height: 10px;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='white'><path d='M13.485 3.515a1 1 0 0 1 0 1.414l-7 7a1 1 0 0 1-1.414 0l-3-3a1 1 0 1 1 1.414-1.414L6 9.586l6.293-6.293a1 1 0 0 1 1.414 0z'/></svg>") center/contain no-repeat;
  opacity: 0;
  transition: opacity .15s;
}
.checkbox input:checked + .checkbox__box {
  background: var(--magenta);
  border-color: var(--magenta);
}
.checkbox input:checked + .checkbox__box::after { opacity: 1; }
.checkbox input:focus-visible + .checkbox__box {
  box-shadow: 0 0 0 4px rgba(166, 25, 92, 0.18);
}

.checkbox a { color: var(--magenta); text-decoration: none; font-weight: 600; }
.checkbox a:hover { text-decoration: underline; }
.consent__rol { color: var(--magenta); font-weight: 600; }

/* ------- Submit ------- */
.btn-submit {
  margin-top: 6px;
  width: 100%;
  padding: 16px 20px;
  font-size: 16px;
  font-weight: 700;
  font-family: inherit;
  color: #fff;
  background: linear-gradient(135deg, var(--magenta), var(--magenta-dark));
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
  letter-spacing: 0.3px;
  box-shadow: var(--shadow);
  transition: transform .1s, box-shadow .15s, filter .15s;
}
.btn-submit:hover { box-shadow: var(--shadow-hover); filter: brightness(1.05); }
.btn-submit:active { transform: translateY(1px); }

.powered {
  margin: 8px 0 0;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}
.powered strong { color: var(--magenta); font-weight: 700; }

/* ------- Responsive ------- */
@media (max-width: 700px) {
  .form__columnas { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .page          { padding: 20px 14px; }
  .card__header  { padding: 28px 22px 22px; }
  .form          { padding: 22px 22px 28px; }
  .card__title   { font-size: 20px; }
  .field-row     { grid-template-columns: 1fr; }
}
