* {
  font-family: "Roboto", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  box-sizing: border-box;
}

body {
  color: #0f172a;
  line-height: 1.5;
}

form {
  display: block;
}

form[hidden] {
  display: none;
}

.container {
  max-width: 800px;
  margin: 0 auto;
}

.form_wrapper {
  width: 100%;
  padding-right: 15px;
  padding-left: 15px;
  margin-right: auto;
  margin-left: auto;
}

.form-card {
  background: #ffffff;
  border: 1px solid #94a3b8;
  border-radius: 8px;
  padding: 24px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

fieldset {
  border: none;
  border-top: 1px solid #e2e8f0;
  padding: 16px 0 8px;
  margin-bottom: 8px;
}

legend {
  font-weight: 700;
  font-size: 0.85rem;
  text-transform: uppercase;
  color: #475569;
  padding: 0 0 8px;
}

.instruction {
  font-size: 0.9rem;
  color: #475569;
  margin-bottom: 12px;
}

.field {
  margin-bottom: 14px;
}

.field label {
  padding-top: 10px;
  padding-left: 5px;
  display: flex;
  flex-direction: column;
  font-size: 14px;
  transition: all 0.3s ease-in;
}

.field > input,
.field > select,
.field > textarea {
  height: 30px;
  margin-top: 4px;
}

.field > textarea {
  height: auto;
  min-height: 80px;
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="number"],
select,
textarea {
  border: none;
  border-bottom: 1px solid black;
  width: 90%;
  color: #707070;
  background-color: #fff;
}

textarea {
  border: 1px solid #94a3b8;
  border-radius: 4px;
  padding: 6px;
}

select:disabled,
input:disabled {
  color: #b0b0b0;
  border-color: #d0d0d0;
  cursor: not-allowed;
}

/* --- Campos condicionales ("Otro") --- */
.field-conditional {
  padding-left: 12px;
  border-left: 2px solid #eff6ff;
}

.field-conditional[hidden] {
  display: none;
}

/* --- Errores de validación --- */
.field-error {
  display: block;
  color: #b91c1c;
  font-size: 0.8rem;
  min-height: 1em;
  margin-top: 2px;
}

.field-hint {
  display: block;
  color: #475569;
  font-size: 0.8rem;
}

.field-hint[hidden] {
  display: none;
}

/* --- Dual listbox (Especialidades) --- */
.dual-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin: 10px 0 8px;
}

.dual-pane {
  border: 1px solid #94a3b8;
  border-radius: 8px;
  padding: 14px;
  background: #fafafa;
  min-height: 160px;
}

.dual-pane h3 {
  font-size: 0.8rem;
  font-weight: 700;
  color: #475569;
  text-transform: uppercase;
  margin: 0;
}

/* Cabecera del panel "Disponibles": título + buscador en la misma línea
   en desktop. En móvil (ver media query) se apilan para que el buscador
   ocupe todo el ancho y sea más fácil de tocar. */
.dual-pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  border-bottom: 1px solid #e2e8f0;
  padding-bottom: 6px;
}

.especialidades-buscador {
  height: 26px;
  width: 130px;
  flex: 0 0 auto;
  border: 1px solid #94a3b8;
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 0.8rem;
  color: #0f172a;
  background-color: #ffffff;
}

.especialidades-buscador::-webkit-search-cancel-button {
  cursor: pointer;
}

.dual-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dual-row {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  padding: 8px 12px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
  font-weight: 500;
}

/* El texto es lo prioritario dentro de la fila; el botón se ajusta a su
   contenido en vez de repartirse el espacio con el texto. */
.dual-row > span {
  flex: 1 1 auto;
  margin-right: 10px;
}

.btn-action {
  width: auto;
  background: white;
  border: 1px solid #94a3b8;
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  min-height: 36px;
  min-width: 36px;
  flex: 0 0 auto;
}

/* Botón "+ Añadir" del panel de disponibles: más discreto que el texto,
   pero sin bajar del tamaño mínimo de zona táctil recomendado en móvil
   (24x24 CSS px, WCAG 2.5.8). */
.btn-add {
  padding: 3px 8px;
  font-size: 0.7rem;
  min-height: 28px;
  min-width: 28px;
}

.btn-action:hover:not(:disabled) {
  background: #1d4ed8;
  color: white;
  border-color: #1d4ed8;
}

.btn-action:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-action.btn-delete {
  color: #b91c1c;
}

.btn-action.btn-delete:hover:not(:disabled) {
  background: #b91c1c;
  color: white;
  border-color: #b91c1c;
}

.action-group {
  display: flex;
  gap: 4px;
}

@media (max-width: 640px) {
  .dual-grid {
    grid-template-columns: 1fr;
  }

  /* Propuesta móvil: título y buscador apilados, buscador a ancho
     completo, más fácil de tocar y de leer en pantallas estrechas. */
  .dual-pane-header {
    flex-direction: column;
    align-items: stretch;
  }

  .especialidades-buscador {
    width: 100%;
    height: 34px;
  }
}

/* --- Checkbox de política de privacidad --- */
.field-checkbox {
  margin-bottom: 14px;
}

.checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.85rem;
  color: #0f172a;
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  margin-top: 2px;
  width: auto;
  flex: 0 0 auto;
}

.link-button {
  background: none;
  border: none;
  padding: 0;
  width: auto;
  min-height: 0;
  color: #1d4ed8;
  text-decoration: underline;
  font-size: inherit;
  font-weight: 500;
  cursor: pointer;
}

/* --- Popup / overlay (política de privacidad) --- */
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  z-index: 9998;
}

.overlay[hidden] {
  display: none;
}

.popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #ffffff;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  z-index: 9999;
  width: 90%;
  max-width: 700px;
  max-height: 80vh;
  overflow: auto;
}

.popup[hidden] {
  display: none;
}

.popup-header {
  display: flex;
  align-items: center;
  margin-bottom: 12px;
  border-bottom: 1px solid #e2e8f0;
  padding-bottom: 8px;
}

.popup-header h4 {
  margin: 0;
  font-weight: 700;
  font-size: 1rem;
  color: #0f172a;
}

.popup-body {
  font-size: 0.85rem;
  color: #475569;
}

.popup-body p {
  margin-bottom: 10px;
}

.close {
  width: auto;
  min-height: 0;
  background: none;
  border: 0;
  margin-left: auto;
  padding: 0 0 0 12px;
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1;
  color: #000000;
  opacity: 0.5;
}

.close:hover {
  opacity: 0.9;
}

/* --- Botón submit / estado de carga --- */

/* Reset genérico: mínimo e inofensivo, para no contaminar los botones de
   acción del dual-listbox (.btn-action/.btn-add). El estilo visual real
   de cada botón se define en su propia clase/id. */
button {
  -webkit-appearance: none;
  font-family: inherit;
  cursor: pointer;
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

#btnSubmit {
  display: block;
  width: 100%;
  max-width: 320px;
  margin: 20px auto 0;
  background-color: #007bff;
  color: #ffffff;
  border: 2px solid #1d4ed8;
  border-radius: 6px;
  padding: 10px 0;
  font-size: 0.95rem;
  font-weight: 700;
  text-align: center;
  transition: background-color 0.2s, border-color 0.2s;
}

#btnSubmit:hover:not(:disabled) {
  background-color: #1e40af;
  border-color: #1e40af;
}

#loadingContainer {
  display: none;
  margin-top: 8px;
  color: #475569;
  text-align: center;
}

span[class^="dot-"] {
  opacity: 0;
}
.dot-one { animation: dot-one 2s infinite linear; }
.dot-two { animation: dot-two 2s infinite linear; }
.dot-three { animation: dot-three 2s infinite linear; }

@keyframes dot-one {
  0% { opacity: 0; } 15% { opacity: 0; } 25% { opacity: 1; } 100% { opacity: 1; }
}
@keyframes dot-two {
  0% { opacity: 0; } 25% { opacity: 0; } 50% { opacity: 1; } 100% { opacity: 1; }
}
@keyframes dot-three {
  0% { opacity: 0; } 50% { opacity: 0; } 75% { opacity: 1; } 100% { opacity: 1; }
}

/* Firefox / Chrome number spinner cleanup (heredado) */
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type="number"] {
  -moz-appearance: textfield;
}

*:focus-visible {
  outline: 3px solid #1d4ed8;
  outline-offset: 2px;
}
