:root {
  color-scheme: light;
  --bg: #eef5fb;
  --card: #ffffff;
  --text: #162033;
  --muted: #55677f;
  --line: #d7e2ee;
  --primary: #0069b4;
  --primary-dark: #004f87;
  --soft: #e8f5fb;
  --danger: #b42318;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

a {
  color: var(--primary);
}

.public-header,
.public-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem clamp(1rem, 3vw, 2rem);
  background: var(--card);
  border-bottom: 1px solid var(--line);
}

.public-footer {
  border-top: 1px solid var(--line);
  border-bottom: 0;
  color: var(--muted);
  font-size: .9rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: .75rem;
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  display: inline-flex;
  width: 2.4rem;
  height: 2.4rem;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--soft);
  color: var(--primary-dark);
  font-weight: 800;
}

.brand small,
.eyebrow {
  display: block;
  color: var(--muted);
  font-size: .85rem;
}

.public-header nav {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.public-header nav a {
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
}

.public-main {
  width: min(1120px, calc(100% - 2rem));
  margin: 2rem auto 3rem;
}

.public-hero,
.public-card,
.form-section,
.confirmation-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 12px 30px rgba(22, 32, 51, .06);
}

.public-hero {
  padding: clamp(1.5rem, 3vw, 3rem);
  margin-bottom: 1.5rem;
}

.public-hero-small {
  padding: clamp(1.25rem, 2vw, 2rem);
}

.public-hero h1 {
  margin: .25rem 0 .75rem;
  font-size: clamp(2rem, 4vw, 3.5rem);
  line-height: 1.05;
}

.public-hero p {
  max-width: 760px;
  margin: 0;
  color: var(--muted);
  font-size: 1.05rem;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
}

.public-card {
  padding: 1.5rem;
}

.public-card-muted {
  background: #f8fbff;
}

.public-card h2,
.form-section legend {
  margin: 0 0 .5rem;
  font-size: 1.25rem;
  font-weight: 800;
}

.public-card p,
.confirmation-card p {
  color: var(--muted);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.65rem;
  padding: .65rem 1.5rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  text-decoration: none;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.button:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(22, 32, 51, 0.1);
}

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

.button-primary {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.button-primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

.button-secondary {
  background: white;
  color: var(--primary-dark);
  border-color: var(--line);
}

.button-secondary:hover {
  background: var(--soft);
  border-color: var(--primary);
}

.public-form {
  display: grid;
  gap: 1.5rem;
}

.form-section {
  padding: 1.5rem;
  position: relative;
}

.form-section legend {
  position: relative;
  padding-left: 2rem;
  padding-bottom: 0.75rem;
  margin-bottom: 1rem;
  border-bottom: 2px solid var(--primary);
}

/* Iconos para secciones */
.form-section legend::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 1.5rem;
  height: 1.5rem;
  background-size: contain;
  background-repeat: no-repeat;
}

.form-section:nth-of-type(1) legend::before {
  /* Identificación */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%230069b4'%3E%3Cpath d='M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z'/%3E%3C/svg%3E");
}

.form-section:nth-of-type(2) legend::before {
  /* Documento */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%230069b4'%3E%3Cpath d='M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8l-8-6zm2 16H8v-2h8v2zm0-4H8v-2h8v2zm0-4H8V8h8v2z'/%3E%3C/svg%3E");
}

.form-section:nth-of-type(3) legend::before {
  /* Contacto */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%230069b4'%3E%3Cpath d='M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 3c1.66 0 3 1.34 3 3s-1.34 3-3 3-3-1.34-3-3 1.34-3 3-3zm0 14.2c-2.5 0-4.71-1.28-6-3.22.03-1.99 4-3.08 6-3.08 1.99 0 5.97 1.09 6 3.08-1.29 1.94-3.5 3.22-6 3.22z'/%3E%3C/svg%3E");
}

.form-section:nth-of-type(4) legend::before {
  /* Representantes */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%230069b4'%3E%3Cpath d='M9 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4zm6 3c1.11 0 2-1.34 2-3-1.11 0-2.67 1.34-2 3zm2 1h6v2h-6z'/%3E%3C/svg%3E");
}

.form-section:nth-of-type(5) legend::before {
  /* Documentacion */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%230069b4'%3E%3Cpath d='M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-8 14H7v-2h4v2zm6-4H7v-2h10v2zm0-4H7V7h10v2z'/%3E%3C/svg%3E");
}

.form-section:nth-of-type(6) legend::before {
  /* Privacidad */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%230069b4'%3E%3Cpath d='M12 1L3 5v6c0 5.55 3.84 10.74 9 12 5.16-1.26 9-6.45 9-12V5l-9-4zm0 10.99h7c-.53 4.12-3.28 7.72-7 8.77V12H5V6.3l7-3.11v8.8z'/%3E%3C/svg%3E");
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.second-representative {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px dashed var(--line);
}

/* Cajas de representantes */
.representative-box {
  display: flex;
  flex-direction: column;
  width: 100%;
  padding: 1.25rem;
  margin-top: 1.5rem;
  background: var(--soft);
  border-radius: 12px;
  border-left: 4px solid var(--primary);
  transition: all 0.3s ease;
}

.representative-box .form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  width: 100%;
}

.representative-box .field-wide {
  grid-column: 1 / -1;
}

.representative-box.field-hidden {
  animation: slideOut 0.3s ease forwards;
}

.representative-box.field-visible {
  animation: slideIn 0.3s ease forwards;
}

.subsection-title {
  margin: 0 0 1rem 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary);
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--line);
}

.field {
  display: grid;
  gap: .35rem;
}

.field-wide {
  grid-column: 1 / -1;
}

.field label {
  font-weight: 700;
  word-wrap: break-word;
  word-break: break-word;
  overflow-wrap: break-word;
}

.field-help {
  margin: -.35rem 0 .25rem;
  color: var(--muted);
  font-size: .9rem;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: .7rem .8rem;
  font: inherit;
  background: white;
  color: var(--text);
  transition: all 0.2s ease;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 105, 180, 0.1);
}

.field input:disabled,
.field select:disabled,
.field textarea:disabled {
  background: #f5f7fa;
  color: var(--muted);
  cursor: not-allowed;
}

.field textarea {
  min-height: 6rem;
  resize: vertical;
}

/* Validación visual */
.field-valid input,
.field-valid select,
.field-valid textarea {
  border-color: #10b981;
  background-image: linear-gradient(white, white),
                    linear-gradient(135deg, rgba(16, 185, 129, 0.05), rgba(16, 185, 129, 0.02));
  background-origin: border-box;
  background-clip: padding-box, border-box;
}

.field-valid input:focus,
.field-valid select:focus,
.field-valid textarea:focus {
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

.field-invalid input,
.field-invalid select,
.field-invalid textarea {
  border-color: var(--danger);
  background-image: linear-gradient(white, white),
                    linear-gradient(135deg, rgba(180, 35, 24, 0.05), rgba(180, 35, 24, 0.02));
  background-origin: border-box;
  background-clip: padding-box, border-box;
}

.field-invalid input:focus,
.field-invalid select:focus,
.field-invalid textarea:focus {
  box-shadow: 0 0 0 3px rgba(180, 35, 24, 0.1);
}

.field span,
.client-validation-message,
.validation-summary {
  color: var(--danger);
  font-size: .9rem;
  margin-top: 0.3rem;
}

.field-valid ~ span {
  color: #10b981;
}

/* Animaciones para campos condicionales */
.field-hidden {
  animation: slideOut 0.3s ease forwards;
  opacity: 0;
}

.field-visible {
  animation: slideIn 0.3s ease forwards;
  opacity: 1;
}

@keyframes slideIn {
  from {
    opacity: 0;
    max-height: 0;
    overflow: hidden;
    margin-bottom: 0;
  }
  to {
    opacity: 1;
    max-height: 1500px;
    margin-bottom: auto;
  }
}

@keyframes slideOut {
  from {
    opacity: 1;
    max-height: 1500px;
    margin-bottom: auto;
  }
  to {
    opacity: 0;
    max-height: 0;
    overflow: hidden;
    margin-bottom: 0;
  }
}

.checkbox-field {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: 0.75rem;
  border-radius: 8px;
  transition: background-color 0.2s ease;
}

.checkbox-field:hover {
  background-color: var(--soft);
}

.checkbox-field input[type="checkbox"] {
  width: 1.2rem;
  height: 1.2rem;
  min-width: 1.2rem;
  cursor: pointer;
  accent-color: var(--primary);
}

.checkbox-field label {
  cursor: pointer;
  margin: 0;
  font-weight: 600;
}

.document-pending {
  margin-top: .75rem;
  background: #f8fbff;
}

.hp-field {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.form-actions {
  display: flex;
  gap: .75rem;
  flex-wrap: wrap;
}

.confirmation-card {
  padding: 1.5rem;
}

.confirmation-label {
  display: block;
  color: var(--muted);
  margin-bottom: .25rem;
}

.confirmation-card strong {
  display: block;
  font-size: 1.5rem;
  letter-spacing: .04em;
}

@media (max-width: 720px) {
  .public-header,
  .public-footer {
    align-items: flex-start;
    flex-direction: column;
  }

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