/* ==========================================================================
   FORMULARIO PRESENTACIÓN CASO CLÍNICO - COMITÉ DE ÉTICA ASISTENCIAL HCV
   Fidelidad 1:1 con maqueta formulario.jpg
   ========================================================================== */

:root {
  --primary-blue: #203c90;
  --text-dark: #333333;
  --border-input: #cfd5de;
  --border-focus: #284797;
  --font-family: 'Segoe UI', Arial, -apple-system, sans-serif;
}

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

body {
  font-family: var(--font-family);
  background-color: #ffffff;
  color: var(--text-dark);
  line-height: 1.35;
  padding: 10px 16px 40px;
  -webkit-font-smoothing: antialiased;
}

/* Contenedor idéntico al lienzo de la maqueta */
.form-container {
  max-width: 890px;
  margin: 0 auto;
  background-color: #ffffff;
}

/* ==========================================================================
   ENCABEZADO PRINCIPAL (BANNER AZUL CON DEGRADÉ Y LOGO)
   ========================================================================== */
.main-header {
  background: #203c90 url('recuadro-degrade.png') no-repeat center center;
  background-size: cover;
  padding: 18px 24px 18px 28px;
  margin-bottom: 18px;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-text h1 {
  color: #ffffff;
  font-size: 23px;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  font-family: var(--font-family);
}

.header-logo img {
  height: 98px;
  width: auto;
  display: block;
  object-fit: contain;
}

/* ==========================================================================
   BANNERS DE SECCIÓN CON DEGRADÉ
   ========================================================================== */
.form-section {
  margin-bottom: 22px;
}

.section-banner {
  background: #203c90 url('recuadro-degrade.png') no-repeat center center;
  background-size: cover;
  padding: 7px 16px;
  min-height: 44px;
  display: flex;
  align-items: center;
  margin-bottom: 14px;
}

.section-banner h2 {
  color: #ffffff;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.section-banner-double {
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  min-height: 58px;
  padding: 6px 16px;
}

.sub-banner-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 1px;
}

.sub-banner-label {
  color: #ffffff;
  font-size: 14.5px;
  font-weight: 500;
}

/* ==========================================================================
   BOTONES DESTACADOS DE ANEXOS (HOVER Y POPUPS)
   ========================================================================== */
.anexo-highlight-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 12px;
  border-radius: 20px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  text-decoration: none;
  user-select: none;
  outline: none;
  line-height: 1.2;
}

.anexo-icon {
  font-size: 13px;
  line-height: 1;
}

.anexo-text {
  letter-spacing: 0.3px;
  font-weight: 800;
}

.anexo-badge-sub {
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 12px;
  transition: all 0.2s ease;
}

/* Variante Anexo 1 (en banner azul superior) */
.header-anexo {
  background: #ffffff;
  color: #1a357e;
  border-color: rgba(255, 255, 255, 0.95);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18), 0 0 0 2px rgba(255, 255, 255, 0.2);
  animation: pulseHeaderBadge 2.8s infinite ease-in-out;
}

.header-anexo .anexo-badge-sub {
  background: #e6eefa;
  color: #1b3882;
}

.header-anexo:hover {
  background: #f0f6ff;
  color: #0d2259;
  transform: translateY(-1.5px) scale(1.03);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25), 0 0 0 3px rgba(255, 255, 255, 0.4);
}

.header-anexo:hover .anexo-badge-sub {
  background: #d4e3fa;
}

/* Variante Anexo 2 (dentro del formulario) */
.label-with-anexo {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 5px;
}

.label-with-anexo label {
  margin-bottom: 0;
}

.inline-anexo {
  background: #eef4ff;
  color: #1c3c8f;
  border-color: #799be0;
  box-shadow: 0 2px 6px rgba(32, 60, 144, 0.12);
  animation: pulseInlineBadge 3.2s infinite ease-in-out;
}

.inline-anexo .anexo-badge-sub {
  background: #d8e5fc;
  color: #173479;
}

.inline-anexo:hover {
  background: #1c3c8f;
  color: #ffffff;
  border-color: #1c3c8f;
  transform: translateY(-1.5px) scale(1.02);
  box-shadow: 0 4px 12px rgba(28, 60, 143, 0.3);
}

.inline-anexo:hover .anexo-badge-sub {
  background: #ffffff;
  color: #1c3c8f;
}

@keyframes pulseHeaderBadge {
  0%, 100% {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18), 0 0 0 1px rgba(255, 255, 255, 0.2);
  }
  50% {
    box-shadow: 0 3px 12px rgba(255, 255, 255, 0.6), 0 0 0 3px rgba(255, 255, 255, 0.45);
  }
}

@keyframes pulseInlineBadge {
  0%, 100% {
    box-shadow: 0 2px 6px rgba(32, 60, 144, 0.12);
    border-color: #799be0;
  }
  50% {
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.35);
    border-color: #3b82f6;
  }
}

.anexo-clickable {
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.anexo-clickable:hover {
  opacity: 0.9;
}

.anexo-inline-link {
  color: #203c90;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.anexo-inline-link:hover {
  text-decoration: underline;
}

/* ==========================================================================
   CAMPOS DEL FORMULARIO: FILAS Y COLUMNAS
   ========================================================================== */
.section-content {
  padding: 0 2px;
}

.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 11px;
}

.form-group {
  display: flex;
  flex-direction: column;
}

.col-12 { flex: 0 0 100%; width: 100%; }
.col-6  { flex: 1 1 calc(50% - 6px); }
.col-5  { flex: 1 1 calc(38% - 6px); }
.col-4  { flex: 1 1 calc(33.333% - 8px); }
.col-3  { flex: 1 1 calc(24% - 6px); }

/* Etiquetas de campos */
label {
  font-size: 12.5px;
  font-weight: 700;
  color: #3b3b3b;
  margin-bottom: 4px;
  display: block;
}

label .anexo-hint {
  color: #203c90;
  margin-left: 6px;
  font-size: 11px;
}

/* Inputs y Textareas idénticos a la maqueta */
input[type="text"],
input[type="tel"],
input[type="email"],
input[type="number"],
select,
textarea {
  width: 100%;
  height: 36px;
  padding: 6px 10px;
  background-color: #ffffff;
  border: 1px solid var(--border-input);
  border-radius: 5px;
  font-family: inherit;
  font-size: 13.5px;
  color: #222222;
  transition: border-color 0.15s ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--border-focus);
  outline: none;
}

textarea {
  height: auto;
  min-height: 82px;
  resize: vertical;
  line-height: 1.4;
}

/* Dropdown Sexo */
.select-container {
  position: relative;
  width: 100%;
}

.select-container select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 28px;
  cursor: pointer;
}

.select-container::after {
  content: "";
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid #444444;
  pointer-events: none;
}

/* ==========================================================================
   SECCIÓN 2: RADIO BUTTONS Y SELECCIONES
   ========================================================================== */
.radio-selection-block {
  margin-bottom: 12px;
}

.radio-header-label {
  font-size: 12.5px;
  font-weight: 700;
  color: #3b3b3b;
  margin-bottom: 8px;
}

.radio-options-row {
  display: grid;
  grid-template-columns: 1.3fr 1fr 1fr 1fr;
  gap: 12px;
  align-items: flex-start;
  padding: 2px 0 8px;
}

.custom-radio {
  display: inline-flex;
  align-items: flex-start;
  cursor: pointer;
  user-select: none;
}

.custom-radio input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.radio-dot {
  width: 16px;
  height: 16px;
  border: 1px solid #7d8492;
  border-radius: 50%;
  margin-right: 6px;
  margin-top: 2px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-color: #ffffff;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.custom-radio input[type="radio"]:checked + .radio-dot {
  border-color: var(--primary-blue);
}

.radio-dot::after {
  content: "";
  width: 8px;
  height: 8px;
  background-color: var(--primary-blue);
  border-radius: 50%;
  display: none;
}

.custom-radio input[type="radio"]:checked + .radio-dot::after {
  display: block;
}

.radio-label {
  font-size: 11.5px;
  font-weight: 600;
  color: #383838;
  line-height: 1.25;
}

/* Sub-grupos y bloqueo dinámico */
.sub-group {
  margin-bottom: 8px;
  padding: 10px 14px;
  border-radius: 6px;
  border: 1.5px solid transparent;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  background-color: transparent;
}

.sub-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.sub-group-title {
  font-size: 13px;
  font-weight: 700;
  color: #383838;
  margin-bottom: 0;
  transition: color 0.2s ease;
}

/* Estado Activo / Habilitado */
.sub-group.is-active {
  background-color: #f7faff;
  border-color: #8bb5f8;
  box-shadow: 0 2px 10px rgba(32, 60, 144, 0.08);
}

.sub-group.is-active .sub-group-title {
  color: #173884;
}

/* Estado Bloqueado */
.sub-group.is-locked {
  background-color: #f6f8fb;
  border-color: #d7e0ea;
  border-style: dashed;
  opacity: 0.58;
  user-select: none;
}

.sub-group.is-locked .sub-group-title {
  color: #8c97a5;
  text-decoration: line-through;
}

.sub-group.is-locked label {
  color: #8c97a5;
}

.sub-group.is-locked input {
  background-color: #eceff4 !important;
  border-color: #d3dae3 !important;
  color: #8a96a4 !important;
  cursor: not-allowed !important;
  pointer-events: none;
}

.sub-group.is-locked input::placeholder {
  color: #a4b0bf;
  font-style: italic;
  font-size: 11px;
}

/* Píldoras de estado de bloqueo */
.lock-indicator {
  display: flex;
  align-items: center;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 14px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
  animation: fadeInPill 0.25s ease;
}

.status-pill.locked {
  background-color: #fff1f0;
  color: #cf1322;
  border: 1px solid #ffa39e;
}

.status-pill.active {
  background-color: #f6ffed;
  color: #389e0d;
  border: 1px solid #b7eb8f;
}

@keyframes fadeInPill {
  from { opacity: 0; transform: translateY(-3px); }
  to { opacity: 1; transform: translateY(0); }
}

.or-label {
  font-size: 12.5px;
  font-weight: 700;
  color: #383838;
  margin: 3px 0 5px 0;
  transition: opacity 0.2s ease;
}

.or-label.is-muted {
  opacity: 0.25;
}

/* ==========================================================================
   SECCIÓN 3: ANTECEDENTES Y URGENCIAS
   ========================================================================== */
.vital-urgency-row {
  display: flex;
  align-items: center;
  gap: 20px;
  margin: 12px 0 8px;
}

.vital-label {
  font-size: 12.5px;
  font-weight: 700;
  color: #383838;
}

.vital-options {
  display: flex;
  gap: 18px;
}

.inline-radio {
  display: inline-flex;
  align-items: center;
}

.inline-radio .radio-dot {
  margin-top: 0;
}

.disclaimer-text {
  margin: 16px 0 24px;
}

.disclaimer-text p {
  font-size: 12px;
  color: #4a4a4a;
  line-height: 1.35;
}

.disclaimer-text strong {
  font-weight: 700;
  color: #222222;
}

/* ==========================================================================
   BOTÓN DE ENVÍO (PILL NAVY IDENTIFICADOR DE LA MAQUETA)
   ========================================================================== */
.button-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 10px;
}

.pill-submit-button {
  background: linear-gradient(180deg, #375484 0%, #29406a 100%);
  color: #ffffff;
  border: none;
  border-radius: 35px;
  padding: 12px 42px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.2px;
  cursor: pointer;
  box-shadow: 0 3px 8px rgba(35, 60, 105, 0.35);
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: 240px;
}

.pill-submit-button:hover {
  background: linear-gradient(180deg, #3f6096 0%, #2e4a7d 100%);
  box-shadow: 0 5px 12px rgba(35, 60, 105, 0.45);
  transform: translateY(-1px);
}

.pill-submit-button:active {
  transform: translateY(0);
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ==========================================================================
   MODALES (ÉXITO Y ANEXOS)
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(10, 20, 40, 0.55);
  backdrop-filter: blur(2px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  padding: 16px;
}

.modal-backdrop.active {
  display: flex;
}

.modal-card {
  background: #ffffff;
  border-radius: 6px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 28px 24px;
  text-align: center;
}

.modal-large {
  max-width: 600px;
  padding: 0;
  text-align: left;
}

.modal-check-circle {
  width: 54px;
  height: 54px;
  background: #e8f5e9;
  color: #2e7d32;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: bold;
  margin: 0 auto 14px;
}

.modal-card h3 {
  font-size: 20px;
  color: #1f3d8a;
  margin-bottom: 10px;
}

.modal-desc {
  font-size: 14px;
  color: #444444;
  margin-bottom: 14px;
  line-height: 1.45;
}

.dest-email {
  color: #1f3d8a;
  background: #edf2fc;
  padding: 2px 6px;
  border-radius: 4px;
  display: inline-block;
  margin-top: 4px;
}

.activation-notice {
  background: #fffbe6;
  border: 1px solid #ffe58f;
  border-radius: 4px;
  padding: 10px 12px;
  font-size: 12px;
  color: #614700;
  text-align: left;
  line-height: 1.4;
  margin-bottom: 18px;
}

.modal-top-bar {
  background: #203c90;
  color: #ffffff;
  padding: 12px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-top-bar h3 {
  font-size: 15px;
  color: #ffffff;
  margin-bottom: 0;
}

.close-x {
  background: transparent;
  border: none;
  color: #ffffff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.modal-body-scroll {
  padding: 18px;
  overflow-y: auto;
  font-size: 13px;
  line-height: 1.5;
  color: #333333;
}

.anexo-intro {
  font-weight: 600;
  margin-bottom: 10px;
  color: #1f3d8a;
}

.anexo-bullets {
  padding-left: 20px;
}

.anexo-bullets li {
  margin-bottom: 8px;
}

.anexo-note {
  margin-top: 14px;
  padding: 12px 14px;
  background-color: #f0f4fa;
  border-left: 4px solid #203c90;
  border-radius: 4px;
  font-size: 13px;
  line-height: 1.5;
  color: #2c3e50;
  font-style: italic;
}

.anexo-note p {
  margin: 0;
}

.modal-bottom-bar,
.modal-buttons {
  display: flex;
  gap: 10px;
  justify-content: center;
  padding: 12px 18px;
  background: #f8fafc;
  border-top: 1px solid #e9ecef;
}

.btn-done,
.btn-print {
  padding: 9px 18px;
  border-radius: 5px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s ease;
}

.btn-done {
  background: #203c90;
  color: #ffffff;
}

.btn-done:hover {
  background: #172d6d;
}

/* ==========================================================================
   CLÁUSULA DE PROTECCIÓN DE DATOS, RESERVA Y CIBERSEGURIDAD
   ========================================================================== */
.legal-compliance-card {
  background-color: #f7f9fc;
  border: 1px solid #cdd7e5;
  border-left: 4px solid #203c90;
  border-radius: 5px;
  padding: 14px 18px;
  margin: 18px 0 22px;
}

.legal-compliance-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.legal-shield-icon {
  font-size: 16px;
}

.legal-compliance-header h4 {
  font-size: 13px;
  font-weight: 700;
  color: #1f3d8a;
  letter-spacing: 0.2px;
  margin: 0;
  flex: 1;
}

.legal-link-detail {
  font-size: 11.5px;
  color: #203c90;
  text-decoration: underline;
  cursor: pointer;
  font-weight: 600;
  white-space: nowrap;
}

.legal-link-detail:hover {
  color: #172d6d;
}

.legal-compliance-body p {
  font-size: 12px;
  color: #4a5568;
  line-height: 1.45;
}

.legal-compliance-body strong {
  color: #2d3748;
}

.legal-consent-group {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed #d6dfea;
}

.consent-checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.consent-checkbox-label input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.checkbox-custom {
  width: 17px;
  height: 17px;
  border: 1.5px solid #203c90;
  border-radius: 3px;
  background-color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
  transition: all 0.15s ease;
}

.consent-checkbox-label input[type="checkbox"]:checked + .checkbox-custom {
  background-color: #203c90;
}

.consent-checkbox-label input[type="checkbox"]:checked + .checkbox-custom::after {
  content: "✓";
  color: #ffffff;
  font-size: 12px;
  font-weight: bold;
  line-height: 1;
}

.consent-text {
  font-size: 12px;
  color: #2d3748;
  line-height: 1.35;
}

.security-footer-badge {
  text-align: center;
  font-size: 11.5px;
  color: #5a6a85;
  margin-top: 14px;
}

.security-footer-badge .lock-small {
  font-size: 13px;
  margin-right: 2px;
}

.legal-section-item {
  margin-bottom: 14px;
}

.legal-section-item h4 {
  font-size: 13.5px;
  color: #1f3d8a;
  margin-bottom: 4px;
  font-weight: 700;
}

.legal-section-item p {
  font-size: 12.5px;
  color: #334155;
  line-height: 1.45;
}

/* ==========================================================================
   RESPONSIVE DESIGN (Móvil y Pantallas Angostas)
   ========================================================================== */
@media (max-width: 768px) {
  body {
    padding: 8px 6px;
  }

  .header-inner {
    flex-direction: column-reverse;
    text-align: center;
    gap: 12px;
  }

  .header-text h1 {
    font-size: 16px;
  }

  .header-logo img {
    height: 70px;
  }

  .col-6, .col-5, .col-4, .col-3 {
    flex: 0 0 100%;
    width: 100%;
  }

  .radio-options-row {
    flex-direction: column;
    gap: 10px;
  }

  .section-banner h2 {
    font-size: 16px;
  }

  .vital-urgency-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .pill-submit-button {
    width: 100%;
  }
}

/* ==========================================================================
   IMPRESIÓN OFICIAL
   ========================================================================== */
@media print {
  body {
    padding: 0 !important;
  }

  .form-container {
    max-width: 100% !important;
  }

  .pill-submit-button,
  .anexo-hint,
  .modal-backdrop {
    display: none !important;
  }

  .main-header,
  .section-banner {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
}

/* Captcha y mensajes de error del envío */
.captcha-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 20px 0 8px;
}

.form-error {
  color: #b00020;
  font-size: 14px;
  margin: 8px 0 0;
  text-align: center;
}

.form-error[hidden] {
  display: none;
}

.captcha-label {
  font-size: 14px;
  margin-bottom: 8px;
}

.captcha-box {
  display: flex;
  align-items: center;
  gap: 12px;
}

.captcha-box img {
  border: 1px solid #c9d2e3;
  border-radius: 6px;
  background: #f4f6fa;
}

.captcha-reload {
  background: none;
  border: none;
  color: #203c90;
  font-size: 14px;
  text-decoration: underline;
  cursor: pointer;
}

.captcha-input {
  width: 160px;
  margin-top: 10px;
  text-align: center;
  font-size: 18px;
  letter-spacing: 4px;
  text-transform: uppercase;
}
