/* --- Definición de la paleta de colores y variables --- */
:root {
  --tecnm-blue-dark: #003366;
  --tecnm-blue-light: #005cb9;
  --white: #ffffff;
  --gray-light: #f8f9fa;
  --gray-border: #ced4da;
  --gray-text: #495057;
  --danger-red: #dc3545;
  --danger-bg: #f8d7da;
  --success-green: #28a745;
  --success-bg: #d4edda;
  --warning-orange: #ffc107;
  --info-blue: #17a2b8;
  --black-text: #212529;
  --border-radius-lg: 20px;
  --border-radius-md: 10px;
  --border-radius-sm: 50px;
}

/* --- Estilos base y del cuerpo de la página --- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Poppins", sans-serif;
  background: #f4f6f9; /* changed to a very light gray background */
  min-height: 100vh;
  padding: 20px;
  color: var(--gray-text);
  display: flex;
  justify-content: center;
  align-items: center;
}

/* --- Contenedor principal del formulario --- */
.container {
  max-width: 900px; /* Default max width, will be overridden or adjusted for some pages if needed */
  width: 100%;
  margin: 0 auto;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-radius: var(--border-radius-lg);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08); /* Adjusted shadow to match light background */
  overflow: hidden;
  animation: slideUp 0.6s ease-out;
}

.container-login {
  max-width: 450px !important;
}
.container-register {
  max-width: 900px !important;
}
.container-options {
  max-width: 600px !important;
}
.container-otp {
  max-width: 600px !important;
}
.container-pwd {
  max-width: 500px !important;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* --- Header del Formulario --- */
.header {
  background: linear-gradient(
    135deg,
    var(--tecnm-blue-light) 0%,
    var(--tecnm-blue-dark) 100%
  );
  color: var(--white);
  padding: 2rem;
  text-align: center;
  position: relative;
  overflow: hidden;
  border-top-left-radius: var(--border-radius-lg);
  border-top-right-radius: var(--border-radius-lg);
}

.header::before {
  content: "";
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(
    circle,
    rgba(255, 255, 255, 0.1) 0%,
    transparent 70%
  );
  animation: rotate 20s linear infinite;
}

@keyframes rotate {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.header h2 {
  font-size: 2.2rem;
  margin-bottom: 0.5rem;
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
}

.header h1 {
  font-size: 3rem;
  margin-bottom: 0.5rem;
  position: relative;
  z-index: 1;
}

.header .subtitle {
  font-size: 1.1rem;
  opacity: 0.9;
  position: relative;
  z-index: 1;
}

.header .subtitle strong {
  color: var(--white);
  font-weight: 600;
}

.logo {
  max-width: 180px;
  margin-bottom: 1rem;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.2));
}

/* --- Contenedores de contenido --- */
.form-content,
.form-container,
.selection-content {
  padding: 2.5rem;
  text-align: center;
}

.form-content p {
  margin-bottom: 1.5rem;
  line-height: 1.5;
  color: var(--gray-text);
}

/* --- Mensajes de error y estado --- */
.db-error {
  background: linear-gradient(135deg, #ff6b6b, #ee5a52);
  color: var(--white);
  padding: 1rem;
  border-radius: var(--border-radius-md);
  margin-bottom: 2rem;
  text-align: center;
  box-shadow: 0 5px 15px rgba(238, 90, 82, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
}

.error-message {
  background: linear-gradient(135deg, #ff6b6b, #ee5a52);
  color: var(--white);
  padding: 1rem;
  border-radius: var(--border-radius-md);
  margin-bottom: 2rem;
  text-align: center;
  box-shadow: 0 5px 15px rgba(238, 90, 82, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
}

.error-text {
  color: var(--danger-red);
  font-size: 0.85rem;
  margin-top: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.error-text::before {
  content: "\f071";
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  font-size: 0.8rem;
}

.message-box {
  padding: 1rem;
  margin-bottom: 1.5rem;
  border-radius: var(--border-radius-md);
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  font-weight: 600;
}

.message-box.success {
  background-color: var(--success-bg);
  color: var(--success-green);
  border: 1px solid var(--success-green);
  box-shadow: 0 5px 15px rgba(40, 167, 69, 0.2);
}

.message-box.error {
  background: linear-gradient(135deg, #ff6b6b, #ee5a52);
  color: var(--white);
  border: 1px solid var(--danger-red);
  box-shadow: 0 5px 15px rgba(238, 90, 82, 0.3);
  padding: 1.5rem;
}
.message-box.error p {
  margin: 0.2rem 0;
  color: var(--white);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.info-notice {
  margin-top: 1.5rem;
  padding: 1rem;
  background: rgba(0, 92, 185, 0.05);
  border-radius: var(--border-radius-md);
  border: 1px dashed var(--tecnm-blue-light);
  font-size: 0.9rem;
  color: var(--gray-text);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-align: left;
  animation: fadeIn 0.8s ease-out;
}

.info-notice i {
  color: var(--tecnm-blue-light);
  font-size: 1.2rem;
}

/* --- Estilo para las secciones del formulario (fieldset) --- */
fieldset {
  border: none;
  margin-bottom: 2rem;
  background: var(--gray-light);
  border-radius: 15px;
  padding: 1.5rem;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
  transition: transform 0.3s ease;
}

fieldset:hover {
  transform: translateY(-2px);
}

legend {
  background: linear-gradient(
    135deg,
    var(--tecnm-blue-light),
    var(--tecnm-blue-dark)
  );
  color: var(--white);
  padding: 0.8rem 1.5rem;
  border-radius: var(--border-radius-sm);
  font-weight: 600;
  margin-bottom: 1rem;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* --- Rejilla para los campos del formulario --- */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
}

.full-width {
  grid-column: 1 / -1;
}

/* --- Grupo de formulario --- */
.form-group {
  margin-bottom: 1.5rem;
  text-align: left;
  position: relative;
}

/* --- Estilo de etiquetas y campos de entrada --- */
label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: #555;
  font-size: 0.95rem;
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: stretch;
}

input,
select {
  width: 100%;
  padding: 1rem;
  border: 2px solid var(--gray-border);
  border-radius: var(--border-radius-md);
  font-size: 1rem;
  transition: all 0.3s ease;
  background: var(--white);
  outline: none;
  padding-right: 3rem;
}

input:focus,
select:focus {
  border-color: var(--tecnm-blue-light);
  box-shadow: 0 0 0 3px rgba(0, 92, 185, 0.2);
  transform: translateY(-2px);
}

input:valid:not(:placeholder-shown),
select:valid:not([value=""]) {
  border-color: var(--success-green);
}

.input-icon {
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--tecnm-blue-light);
  font-size: 1.1rem;
  pointer-events: none;
}

.toggle-password {
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--tecnm-blue-light);
  font-size: 1.1rem;
  padding: 0;
  display: flex;
  align-items: center;
  transition: color 0.2s ease;
}

.toggle-password:hover {
  color: var(--tecnm-blue-dark);
}

.otp-container {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.otp-container .otp-input {
  width: 50px;
  height: 60px;
  padding: 0 !important;
  padding-right: 0 !important;
  margin: 0;
  letter-spacing: normal !important;
  border: 2px solid var(--gray-border);
  border-radius: var(--border-radius-md);
  font-size: 1.5rem;
  text-align: center;
  transition: all 0.3s ease;
  background-color: #ffffff !important;
  color: #000000 !important;
  -webkit-text-fill-color: #000000 !important;
  caret-color: #000000;
  line-height: 60px;
  outline: none;
  font-family: inherit;
  display: block;
  -moz-appearance: textfield;
  appearance: textfield;
}

.otp-container .otp-input:focus {
  border-color: var(--tecnm-blue-light);
  box-shadow: 0 0 0 3px rgba(0, 92, 185, 0.2);
  transform: translateY(-2px);
}

.otp-container .otp-input:valid:not(:placeholder-shown) {
  border-color: var(--success-green);
}

/* Estilo específico para el input OTP de un solo campo (ej. restablecer contraseña) */
.input-wrapper .otp-input {
  letter-spacing: 10px;
  font-size: 1.5rem;
  text-align: center;
  padding-left: 3rem;
}

/* --- Indicador de fuerza de contraseña --- */
.password-strength {
  margin-top: 0.5rem;
  font-size: 0.8rem;
}

.strength-bar {
  height: 4px;
  background: var(--gray-border);
  border-radius: 2px;
  margin-top: 0.25rem;
  overflow: hidden;
}

.strength-fill {
  height: 100%;
  transition: all 0.3s ease;
  border-radius: 2px;
}

.strength-weak {
  background: var(--danger-red);
  width: 25%;
}
.strength-fair {
  background: var(--warning-orange);
  width: 50%;
}
.strength-good {
  background: var(--info-blue);
  width: 75%;
}
.strength-strong {
  background: var(--success-green);
  width: 100%;
}

/* --- Estilo del botón principal y variantes --- */
.btn,
.btn-login,
.btn-send,
.btn-reset,
.btn-submit {
  background: linear-gradient(
    135deg,
    var(--tecnm-blue-light) 0%,
    var(--tecnm-blue-dark) 100%
  );
  color: var(--white);
  padding: 1rem 2rem;
  border: none;
  border-radius: var(--border-radius-sm);
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  margin-top: 1.5rem;
  transition: all 0.3s ease;
  box-shadow: 0 10px 30px rgba(0, 51, 102, 0.3);
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  z-index: 1;
}

.btn::before,
.btn-login::before,
.btn-send::before,
.btn-reset::before,
.btn-submit::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  transition: all 0.4s ease;
  transform: translate(-50%, -50%);
  z-index: -1;
}

.btn:hover::before,
.btn-login:hover::before,
.btn-send:hover::before,
.btn-reset:hover::before,
.btn-submit:hover::before {
  width: 300px;
  height: 300px;
}

.btn:hover,
.btn-login:hover,
.btn-send:hover,
.btn-reset:hover,
.btn-submit:hover {
  transform: translateY(-3px);
  box-shadow: 0 15px 40px rgba(0, 51, 102, 0.4);
}

.btn:active,
.btn-login:active,
.btn-send:active,
.btn-reset:active,
.btn-submit:active {
  transform: translateY(-1px);
}

/* --- Cuadrícula de Botones (Opciones de registro) --- */
.button-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.btn-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: var(--white);
  padding: 1.5rem 1rem;
  border-radius: var(--border-radius-md);
  transition: all 0.3s ease;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
  font-size: 1.1rem;
  font-weight: 600;
  text-align: center;
  min-height: 120px;
  position: relative;
  overflow: hidden;
  border: 2px solid transparent;
}

.btn-option:hover {
  transform: translateY(-5px);
  box-shadow: 0 12px 25px rgba(0, 0, 0, 0.15);
  border-color: var(--white);
}

.btn-option .icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
  color: rgba(255, 255, 255, 0.8);
  transition: color 0.3s ease;
}

.btn-option:hover .icon {
  color: var(--white);
}

.btn-option.investigador {
  background: linear-gradient(135deg, var(--info-blue) 0%, #117a8b 100%);
}
.btn-option.investigador:hover {
  background: linear-gradient(135deg, #117a8b 0%, var(--info-blue) 100%);
}

.btn-option.alumno {
  background: linear-gradient(
    135deg,
    var(--tecnm-blue-light) 0%,
    var(--tecnm-blue-dark) 100%
  );
}
.btn-option.alumno:hover {
  background: linear-gradient(
    135deg,
    var(--tecnm-blue-dark) 0%,
    var(--tecnm-blue-light) 100%
  );
}

.btn-option.coordinador-campus {
  background: linear-gradient(135deg, var(--warning-orange) 0%, #d39e00 100%);
  color: var(--black-text);
}
.btn-option.coordinador-campus:hover {
  background: linear-gradient(135deg, #d39e00 0%, var(--warning-orange) 100%);
}
.btn-option.coordinador-campus .icon {
  color: rgba(0, 0, 0, 0.6);
}
.btn-option.coordinador-campus:hover .icon {
  color: var(--black-text);
}

.btn-option.coordinador-institucional {
  background: linear-gradient(135deg, var(--success-green) 0%, #1e7e34 100%);
}
.btn-option.coordinador-institucional:hover {
  background: linear-gradient(135deg, #1e7e34 0%, var(--success-green) 100%);
}

/* --- Enlaces secundarios --- */
.links-section {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--gray-border);
}

.links-section p {
  margin-bottom: 1rem;
  color: var(--gray-text);
}

.links-section a {
  color: var(--tecnm-blue-light);
  text-decoration: none;
  font-weight: 500;
  padding: 0.5rem 1rem;
  border-radius: var(--border-radius-sm);
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.links-section a:hover {
  background: rgba(0, 92, 185, 0.1);
  transform: translateY(-2px);
  text-decoration: none;
}

.back-link {
  text-align: center;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--gray-border);
}

.back-link a {
  color: var(--tecnm-blue-light);
  text-decoration: none;
  font-weight: 500;
  padding: 0.5rem 1rem;
  border-radius: var(--border-radius-sm);
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.back-link a:hover {
  background: rgba(0, 92, 185, 0.1);
  transform: translateY(-2px);
  text-decoration: none;
}

/* --- Formas flotantes de fondo --- */
.floating-shapes {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: -1;
}

.shape {
  position: absolute;
  background: rgba(
    0,
    92,
    185,
    0.05
  ); /* Changed from white to light blue for visibility on light bg */
  border-radius: 50%;
  animation: float 6s ease-in-out infinite;
}

.shape:nth-child(1) {
  width: 120px;
  height: 120px;
  top: 15%;
  left: 10%;
  animation-delay: 0s;
}

.shape:nth-child(2) {
  width: 180px;
  height: 180px;
  top: 55%;
  right: 8%;
  animation-delay: 2s;
}

.shape:nth-child(3) {
  width: 90px;
  height: 90px;
  bottom: 15%;
  left: 15%;
  animation-delay: 4s;
}

@keyframes float {
  0%,
  100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-20px);
  }
}

/* --- Diseño Responsivo para móviles --- */
@media (max-width: 768px) {
  body {
    padding: 10px;
  }

  .container,
  .container-login,
  .container-register,
  .container-options,
  .container-otp,
  .container-pwd {
    margin: 10px;
    border-radius: 15px;
  }

  .form-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .header h2 {
    font-size: 1.8rem;
  }

  .form-content,
  .form-container,
  .selection-content {
    padding: 1.5rem;
  }

  legend {
    font-size: 1rem;
    padding: 0.6rem 1rem;
  }

  .button-grid {
    grid-template-columns: 1fr;
  }

  .btn-option {
    min-height: 100px;
    padding: 1rem;
    font-size: 1rem;
  }

  .btn-option .icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
  }

  .otp-container .otp-input {
    width: 40px;
    height: 50px;
    line-height: 50px;
    font-size: 1.2rem;
    padding: 0 !important;
  }
}
