/* ============================================================
   Estilos base y de formularios
   - Visual feedback para estados válido/ inválido
   - Mensajes de error dinámicos
   ============================================================ */

:root {
  --bg: #0b1220;
  --panel: #111a2b;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --primary: #60a5fa;
  --danger: #f87171;
  --success: #34d399;
  --border: #1f2a44;
  --focus: #93c5fd;
}

* {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
}
body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial,
    sans-serif;
  background: linear-gradient(180deg, var(--bg), #0c1322 30%, #0e1627 100%);
  color: var(--text);
  line-height: 1.4;
}

.wrapper {
  width: min(960px, 92vw);
  margin-inline: auto;
  padding: 1.5rem;
}

.site-header,
.site-footer {
  background: transparent;
  border-bottom: 1px solid var(--border);
}
.site-footer {
  border-top: 1px solid var(--border);
  border-bottom: none;
}
.site-header .subtitle {
  color: var(--muted);
  margin-top: 0.25rem;
}

h1,
h2,
legend {
  line-height: 1.1;
}
h1 {
  font-size: clamp(1.5rem, 2.4vw + 1rem, 2.25rem);
  margin: 0;
}
h2 {
  margin: 0 0 0.75rem;
  font-size: 1.25rem;
  color: var(--primary);
}

section {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

form {
  display: grid;
  gap: 1.25rem;
}

fieldset {
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 1rem;
}
legend {
  padding: 0 0.5rem;
  color: var(--muted);
}

.form-control {
  display: grid;
  gap: 0.375rem;
}
.form-control--checkbox {
  grid-template-columns: auto 1fr;
  align-items: start;
  gap: 0.75rem;
}
label {
  font-weight: 600;
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="password"],
input[type="date"] {
  width: 100%;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #0d1729;
  color: var(--text);
  outline: none;
}
input::placeholder {
  color: #6b7280;
}

input:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgb(147 197 253 / 0.15);
}

/* Estados de validación visuales */
.is-valid {
  border-color: rgba(52, 211, 153, 0.8) !important;
  box-shadow: 0 0 0 3px rgb(52 211 153 / 0.15);
}
.is-invalid {
  border-color: rgba(248, 113, 113, 0.85) !important;
  box-shadow: 0 0 0 3px rgb(248 113 113 / 0.15);
}

/* Mensajes */
.help {
  margin-top: 0.125rem;
  color: var(--muted);
  font-size: 0.875rem;
}
.error-message {
  color: var(--danger);
  margin: 0;
  font-size: 0.9rem;
}
/* Oculta el contenedor si no tiene texto */
.error-message:empty {
  display: none;
}
/* Muestra y estiliza SOLO cuando haya mensaje */
.error-message:not(:empty) {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.9rem;
  color: var(--danger);
}
.success {
  color: var(--success);
  font-weight: 600;
}

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

button {
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #12213a;
  color: var(--text);
  cursor: pointer;
  font-weight: 600;
}
button:hover {
  background: #0f1c31;
}
button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
button.secondary {
  background: transparent;
}
