:root {
  --primary-color: #0078d4;
  --secondary-color: #106ebe;
  --accent-color: #2b88d8;
  --background-color: #f5f5f5;
  --text-color: #323130;
  --border-color: #edebe9;
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.12);
  --gradient: linear-gradient(135deg, #0078d4, #106ebe);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Segoe UI", sans-serif;
  /* Cambia la siguiente línea: */
  background: var(--background-color)
    url("https://cdn.bitrix24.es/b15495391/landing/164/164ee2aa6aea49cb44d001c7da59a84c/beta-port-01_1x.jpg")
    no-repeat center center / cover;
  background-attachment: fixed; /* Opcional: hace que el fondo no se mueva al hacer scroll */
  color: var(--text-color);
  line-height: 1.4;
  min-height: 100vh; /* Importante para que el fondo cubra toda la altura */
}

.container {
  max-width: 750px;
  margin: 1rem auto;
  padding: 0 1rem;
}

.form-card {
  background: white;
  border-radius: 4px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  transition: transform 0.2s ease;
}

.form-card:hover {
  transform: translateY(-2px);
}

.form-header {
  background: var(--gradient);
  padding: 1.5rem;
  text-align: center;
}

.form-header h1 {
  color: white;
  font-size: 1.8rem;
  font-weight: 500;
  margin-bottom: 0.3rem;
  letter-spacing: 0.3px;
}

.form-header p {
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.95rem;
}

.section {
  background: white;
  margin: 0.8rem;
  padding: 1.2rem;
  border-radius: 4px;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
  border: 1px solid var(--border-color);
  animation: fadeInUp 0.3s ease-out forwards;
}

.section:hover {
  box-shadow: var(--shadow-md);
}

.section h2 {
  color: var(--primary-color);
  font-size: 1.3rem;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 500;
}

.section h2 i {
  color: var(--accent-color);
  font-size: 1.2rem;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.form-group {
  margin-bottom: 0.8rem;
}

label {
  display: block;
  margin-bottom: 0.4rem;
  font-weight: 500;
  color: var(--text-color);
  font-size: 0.9rem;
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="date"],
select {
  width: 100%;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 0.95rem;
  transition: all 0.2s ease;
  background: white;
  color: var(--text-color);
}

input:focus,
select:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(0, 120, 212, 0.1);
  outline: none;
}

input::placeholder {
  color: #a19f9d;
}

.requirements label,
.ferpa-requirements label {
  display: flex;
  align-items: flex-start;
  padding: 0.8rem;
  background: #fafafa;
  border-radius: 4px;
  margin-bottom: 0.6rem;
  transition: all 0.2s ease;
  cursor: pointer;
  border: 1px solid var(--border-color);
}

.requirements label:hover,
.ferpa-requirements label:hover {
  background: white;
  border-color: var(--primary-color);
  box-shadow: var(--shadow-sm);
}

input[type="checkbox"] {
  margin: 0.2rem 0.8rem 0 0;
  width: 1.2rem;
  height: 1.2rem;
  border-radius: 3px;
  cursor: pointer;
  accent-color: var(--primary-color);
  appearance: none;
  -webkit-appearance: none;
  border: 2px solid var(--primary-color);
  position: relative;
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
}

.requirements label {
  display: none; /* Requirements labels hidden by default */
}

.ferpa-requirements label {
  display: flex; /* Ferpa labels visible by default (within the FERPA section) */
}

input[type="checkbox"]:checked {
  background-color: var(--primary-color);
}

input[type="checkbox"]:checked:after {
  content: "";
  position: absolute;
  left: 4px;
  top: 1px;
  width: 5px;
  height: 10px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.signature-container,
.signature-container-parent {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  margin: 1.5rem 0;
}

#signature-pad,
#signature-pad-parent {
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: white;
  width: 100%;
  max-width: 400px;
  height: 200px;
  cursor: crosshair;
  box-shadow: var(--shadow-sm);
}

.btn-group {
  display: flex;
  gap: 0.8rem;
  margin-top: 0.8rem;
}

button {
  padding: 0.8rem 1.5rem;
  border: none;
  border-radius: 4px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.95rem;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

button.secondary {
  background: #f3f2f1;
  color: var(--text-color);
}

button.secondary:hover {
  background: #e1dfdd;
}

.submit-btn {
  background: var(--primary-color);
  color: white;
  width: 100%;
  padding: 1rem;
  font-size: 1rem;
  margin-top: 1.5rem;
  letter-spacing: 0.3px;
}

.submit-btn:hover {
  background: var(--secondary-color);
  box-shadow: var(--shadow-md);
}

.guardian-section {
  display: none;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease-in-out;
}

.guardian-section.visible {
  display: block;
  max-height: 2000px; /* Adjust as needed */
}

.section-note {
  color: #605e5c;
  font-size: 0.85rem;
  margin-bottom: 0.8rem;
  font-style: italic;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

input:disabled,
select:disabled {
  background-color: #f3f2f1;
  cursor: not-allowed;
  opacity: 0.7;
}

.hidden {
  display: none;
}

[data-tooltip] {
  position: relative;
}

[data-tooltip]:hover::before {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.4rem 0.8rem;
  background: var(--text-color);
  color: white;
  border-radius: 4px;
  font-size: 0.85rem;
  white-space: nowrap;
  z-index: 10;
}

@media (max-width: 480px) {
  .language-switcher {
    top: 10px;
    right: 10px;
  }
  .language-switcher button {
    padding: 5px 10px;
    font-size: 0.8rem;
  }

  .container {
    margin: 0.5rem;
    padding: 0.5rem;
  }

  .form-header {
    padding: 1.2rem 1rem;
  }

  .form-header h1 {
    font-size: 1.3rem; /* Título más pequeño para que no ocupe 4 líneas */
    margin-top: 20px;
  }

  .section {
    margin: 0.6rem;
    padding: 1rem;
  }

  .form-row {
    grid-template-columns: 1fr;
    gap: 0.8rem;
  }

  button {
    padding: 0.7rem 1.2rem;
  }
}

@media (max-width: 400px) {
  .btn-group {
    flex-direction: column; /* Apila botones de "Limpiar" y "Subir" */
    width: 100%;
  }

  .btn-group button {
    width: 100%;
    justify-content: center;
  }

  .mode-selector {
    flex-direction: column; /* Apila "Dibujar" y "Subir" */
  }
}

/* 3. Ajuste de los requisitos (Checkboxes) */
/* En móvil, el texto largo de los requisitos suele verse muy apretado */
.requirements label div,
.ferpa-requirements label div {
  flex: 1;
}

.requirements strong,
.ferpa-requirements strong {
  font-size: 0.9rem;
  line-height: 1.2;
  display: block;
  margin-bottom: 4px;
}

.requirements p,
.ferpa-requirements p {
  font-size: 0.8rem;
  line-height: 1.3;
}

/* 4. Toque amigable (Tap target) */
/* Hace que los checkboxes sean más fáciles de tocar con el dedo */
input[type="checkbox"] {
  min-width: 22px;
  min-height: 22px;
}

/* 5. Evitar que el contenedor de la firma se salga de la pantalla */
.signature-wrapper {
  width: 100%;
  max-width: 100%; /* Cambiado de 400px para que sea fluido */
}

#signature-pad,
#signature-pad-parent {
  max-width: 100%;
  touch-action: none; /* Crucial: evita que la pantalla haga scroll mientras firmas */
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* --- NUEVOS ESTILOS PARA FIRMA DUAL --- */
.signature-wrapper {
  position: relative;
  width: 100%;
  max-width: 400px;
  margin: 10px 0;
}

.signature-viewer {
  border: 2px dashed var(--border-color);
  border-radius: 4px;
  background: #fff;
  width: 100%;
  height: 200px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: all 0.3s ease;
  cursor: default;
  min-height: 200px;
}

.signature-viewer canvas {
  max-width: 100%;
  max-height: 100%;
  display: block;
}

.signature-viewer img {
  max-width: 100%;
  max-height: 100%;
  width: auto; /* Cambiado de 100% para mantener proporción si es pequeña */
  height: auto;
  object-fit: contain;
  display: block;
}

.signature-viewer .hidden-view {
  display: none !important;
  position: absolute; /* Extra seguridad para que no ocupen espacio si fallara el display */
}

.mode-selector {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 10px;
}

.mode-btn {
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  background: #f3f2f1;
  color: var(--text-color);
  border: 1px solid var(--border-color);
}

.mode-btn.active {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

.hidden-view {
  display: none !important;
}

.language-switcher {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
  background: white;
  padding: 5px;
  border-radius: 25px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.language-switcher button {
  border: none;
  background: none;
  padding: 8px 15px;
  cursor: pointer;
  border-radius: 20px;
  font-weight: bold;
  transition: 0.3s;
}

.language-switcher button.active {
  background: #0078d4;
  color: white;
}

.signature-viewer img:not([src]),
.signature-viewer img[src=""],
.signature-viewer img[src*="window.location.href"] {
  display: none !important;
}

.signature-viewer.upload-mode-active {
  cursor: pointer;
}

.upload-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 20px;
  color: #605e5c;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.upload-placeholder i {
  font-size: 3rem;
  color: var(--primary-color);
  margin-bottom: 10px;
}

.upload-placeholder p {
  font-size: 0.9rem;
  max-width: 80%;
}

/* Asegura que el input de Flatpickr use el ancho completo */
.flatpickr-input[readonly] {
  background-color: white !important;
}

/* 2. Agrega estos ajustes para mejorar la visibilidad en móviles */
.flatpickr-calendar {
  z-index: 9999 !important; /* Asegura que el calendario flote sobre todo */
}

@media (max-width: 480px) {
  /* Evita que el zoom automático de iOS rompa el diseño al enfocar el input */
  input[type="text"],
  input[type="email"],
  input[type="tel"],
  input[type="date"],
  select {
    font-size: 16px !important;
  }

  /* Ajusta el tamaño del calendario de Flatpickr para pantallas muy pequeñas */
  .flatpickr-calendar {
    width: 280px !important;
  }
}

/* Asegura que el contenedor del formulario no corte el calendario */
.form-card {
  overflow: visible !important;
}

.section {
  overflow: visible !important;
}
