@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Libre+Baskerville:ital@0;1&display=swap');

/* Marca Credicorp (tomada de los decks de eventos en Figma): negro, magenta y turquesa del logo,
   Inter para texto y Libre Baskerville como serif de acento. La encuesta usa la versión oscura
   (src/survey.css); el admin, esta versión clara. */
:root {
  --brand: #0a0a0a;
  --brand-hover: #262626;
  --brand-contrast: #ffffff;
  --accent: #e93cac;
  --accent-2: #2ad2c9;
  --gradient: linear-gradient(90deg, var(--accent), var(--accent-2));

  --bg: #f4f4f5;
  --surface: #ffffff;
  --text: #0a0a0a;
  --muted: #5f6068;
  --border: #dcdce0;
  --focus: #e93cac;
  --danger: #c0392b;
  --danger-bg: #fdecea;
  --success: #1e7d4f;
  --success-bg: #e6f4ec;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgb(16 24 40 / 0.06), 0 8px 24px rgb(16 24 40 / 0.06);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-serif: 'Libre Baskerville', Georgia, 'Times New Roman', serif;

  color-scheme: light;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
}

h1 {
  margin: 0 0 0.25rem;
  font-size: 1.5rem;
  line-height: 1.25;
}

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* --- Estructura ----------------------------------------------------------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.875rem 1rem;
  background: var(--brand);
  color: var(--brand-contrast);
}

.logo {
  display: block;
  height: 22px;
  width: auto;
}

.page {
  flex: 1;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 1.5rem 1rem 2rem;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem 1.25rem;
}

.lead {
  margin: 0 0 1.5rem;
  color: var(--muted);
}

.footer {
  padding: 1rem;
  text-align: center;
  font-size: 0.8125rem;
  color: var(--muted);
}

/* --- Campos --------------------------------------------------------------- */

.field {
  margin: 0 0 1.25rem;
  padding: 0;
  border: 0;
  min-width: 0;
}

.field > label,
.field > legend {
  display: block;
  margin-bottom: 0.375rem;
  padding: 0;
  font-weight: 600;
  font-size: 0.9375rem;
}

input:not([type='radio'], [type='checkbox']),
select {
  width: 100%;
  min-height: 48px;
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

input:focus-visible,
select:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus) 45%, transparent);
  outline-offset: 1px;
  border-color: var(--focus);
}

input[aria-invalid='true'] {
  border-color: var(--danger);
}

.field-error {
  margin: 0.375rem 0 0;
  color: var(--danger);
  font-size: 0.875rem;
}

.field-error:empty {
  display: none;
}

/* Selector segmentado (perfil y filtros del admin) */
.segmented {
  display: grid;
  grid-auto-columns: 1fr;
  grid-auto-flow: column;
  gap: 0.5rem;
}

.segmented label {
  position: relative;
  cursor: pointer;
}

.segmented input {
  position: absolute;
  opacity: 0;
  inset: 0;
  margin: 0;
  cursor: pointer;
}

.segmented span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-weight: 600;
  text-align: center;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

.segmented input:checked + span {
  border-color: var(--brand);
  background: var(--brand);
  color: var(--brand-contrast);
}

.segmented input:focus-visible + span {
  outline: 3px solid color-mix(in srgb, var(--focus) 45%, transparent);
  outline-offset: 1px;
}

.segmented input[aria-invalid='true'] + span {
  border-color: var(--danger);
}

/* Celular con código de país */
.phone {
  display: flex;
  gap: 0.5rem;
}

.country {
  position: relative;
  flex: 0 0 auto;
}

.country-display {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  height: 100%;
  min-height: 48px;
  padding: 0 1.75rem 0 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%235d6779' stroke-width='1.6'/%3E%3C/svg%3E")
    no-repeat right 0.625rem center;
  white-space: nowrap;
}

.country select {
  position: absolute;
  inset: 0;
  min-height: 0;
  opacity: 0;
  cursor: pointer;
}

.country:has(select:focus-visible) .country-display {
  outline: 3px solid color-mix(in srgb, var(--focus) 45%, transparent);
  outline-offset: 1px;
  border-color: var(--focus);
}

.phone .custom-dial {
  flex: 0 0 5rem;
  width: 5rem;
}

.phone #phone {
  flex: 1;
  min-width: 0;
}

/* Consentimiento */
.checkbox {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  font-size: 0.875rem;
  color: var(--muted);
  cursor: pointer;
}

.checkbox input {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  margin: 0.125rem 0 0;
  accent-color: var(--brand);
}

.checkbox input[aria-invalid='true'] {
  outline: 2px solid var(--danger);
  outline-offset: 1px;
}

/* --- Botones -------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 48px;
  padding: 0.625rem 1.25rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s;
}

.btn:disabled {
  opacity: 0.6;
  cursor: progress;
}

.btn-block {
  width: 100%;
}

.btn-primary {
  background: var(--brand);
  color: var(--brand-contrast);
}

.btn-primary:hover:not(:disabled) {
  background: var(--brand-hover);
}

.btn-secondary {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--brand);
}

.btn-ghost {
  background: transparent;
  color: inherit;
  border-color: color-mix(in srgb, currentColor 35%, transparent);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-sm {
  min-height: 36px;
  padding: 0.25rem 0.75rem;
  font-size: 0.875rem;
}

/* --- Mensajes y estados --------------------------------------------------- */

.form-error {
  margin: 0 0 1rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 0.9375rem;
}

.state {
  text-align: center;
  padding: 2.5rem 1.25rem;
}

.state p {
  color: var(--muted);
  margin: 0 0 1.5rem;
}

.state h1:focus {
  outline: none;
}

.state-icon {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin: 0 auto 1rem;
  border-radius: 50%;
  background: var(--bg);
  font-size: 1.75rem;
}

.state-icon-success {
  background: var(--success-bg);
  color: var(--success);
  font-weight: 700;
}

.spinner {
  width: 32px;
  height: 32px;
  margin: 0 auto 0.75rem;
  border: 3px solid var(--border);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation-duration: 2.4s;
  }
}

@media (min-width: 600px) {
  .page {
    padding-top: 2.5rem;
  }

  .card {
    padding: 2rem;
  }
}
