/* ============================================================
   ESTILOS FORMULARIO DE CONTACTO - MOBILE FIRST
   ============================================================ */

:root {
  --color-bg: #f6f8fb;
  --color-surface: #ffffff;
  --color-border: #d9dee6;
  --color-border-strong: #b7c0cc;
  --color-text: #0f172a;
  --color-text-muted: #5b6577;
  --color-text-soft: #7b8699;
  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-primary-pressed: #1e40af;
  --color-primary-contrast: #ffffff;
  --color-secondary-bg: #eef2ff;
  --color-secondary-bg-hover: #e0e7ff;
  --color-secondary-text: #3730a3;
  --color-danger: #dc2626;
  --color-danger-bg: #fef2f2;
  --color-danger-border: #fecaca;
  --color-success: #15803d;
  --color-success-bg: #f0fdf4;
  --color-success-border: #bbf7d0;
  --color-warning: #92400e;
  --color-warning-bg: #fffbeb;
  --color-warning-border: #fde68a;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 14px rgba(15, 23, 42, 0.10);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.22);
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;
  --space-8: 40px;
  --font-base: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
    Ubuntu, Cantarell, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono",
    monospace;
  --touch-min: 44px;
}

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

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  font-family: var(--font-base);
  font-size: 16px;
  line-height: 1.5;
  color: var(--color-text);
  background: var(--color-bg);
  min-height: 100vh;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom) 0;
}

/* ---------- Layout ---------- */
.app {
  max-width: 640px;
  margin: 0 auto;
  padding: var(--space-5) var(--space-4) var(--space-8) var(--space-4);
}

.app__header {
  text-align: left;
  padding: var(--space-3) var(--space-1) var(--space-6) var(--space-1);
}

.app__title {
  margin: 0 0 var(--space-2) 0;
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--color-text);
}

.app__subtitle {
  margin: 0;
  font-size: 0.95rem;
  color: var(--color-text-muted);
}

/* ---------- Form ---------- */
.form {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
}

.form__actions {
  margin-top: var(--space-6);
}

/* ---------- Campos ---------- */
.field {
  margin: 0 0 var(--space-5) 0;
  border: none;
  padding: 0;
}

.field--attachments {
  padding: var(--space-4);
  border: 1px dashed var(--color-border-strong);
  border-radius: var(--radius-md);
  background: #fbfcfe;
}

.field__label {
  display: block;
  font-weight: 600;
  font-size: 0.95rem;
  margin: 0 0 var(--space-2) 0;
  color: var(--color-text);
  padding: 0;
}

.field__input,
.field__textarea {
  width: 100%;
  border: 1px solid var(--color-border-strong);
  background: #fff;
  color: var(--color-text);
  border-radius: var(--radius-md);
  padding: 14px 14px;
  font-size: 1rem;
  font-family: inherit;
  line-height: 1.4;
  min-height: var(--touch-min);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  appearance: none;
  -webkit-appearance: none;
}

.field__textarea {
  resize: vertical;
  min-height: 140px;
}

.field__input::placeholder,
.field__textarea::placeholder {
  color: var(--color-text-soft);
}

.field__input:hover,
.field__textarea:hover {
  border-color: #9ea7b6;
}

.field__input:focus,
.field__textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
}

.field[data-error="true"] .field__input,
.field[data-error="true"] .field__textarea {
  border-color: var(--color-danger);
  background: #fff5f5;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.14);
}

.field__help {
  display: block;
  margin: var(--space-1) 0 var(--space-2) 0;
  color: var(--color-text-muted);
  font-size: 0.85rem;
}

.field__error {
  display: block;
  margin: var(--space-2) 0 0 0;
  color: var(--color-danger);
  font-size: 0.85rem;
  min-height: 0;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: opacity 0.2s ease, max-height 0.2s ease;
}

.field[data-error="true"] .field__error {
  opacity: 1;
  max-height: 100px;
}

#err_photos,
#err_files {
  display: block;
  margin-top: var(--space-2);
  color: var(--color-danger);
  font-size: 0.85rem;
}

/* ---------- Honeypot ---------- */
.hp {
  position: absolute !important;
  left: -10000px !important;
  top: auto !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  pointer-events: none;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* ---------- Botones ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-weight: 600;
  font-size: 1rem;
  line-height: 1;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  padding: 12px 18px;
  min-height: var(--touch-min);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: transform 0.05s ease, background 0.15s ease,
    border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.25);
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled,
.btn[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.7;
  pointer-events: none;
}

.btn--primary {
  background: var(--color-primary);
  color: var(--color-primary-contrast);
  border-color: var(--color-primary);
  box-shadow: var(--shadow-sm);
}

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

.btn--primary:active {
  background: var(--color-primary-pressed);
  border-color: var(--color-primary-pressed);
}

.btn--secondary {
  background: var(--color-secondary-bg);
  color: var(--color-secondary-text);
  border-color: #c7d2fe;
}

.btn--secondary:hover {
  background: var(--color-secondary-bg-hover);
  border-color: #a5b4fc;
}

.btn--lg {
  padding: 14px 20px;
  font-size: 1rem;
  min-height: 48px;
}

.btn--block {
  width: 100%;
}

.btn__icon {
  font-size: 1.1em;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Estado de carga en botón de envío */
.btn .btn__label--loading {
  display: none;
}

.btn.is-loading .btn__label {
  display: none;
}

.btn.is-loading .btn__label--loading {
  display: inline-flex;
}

.btn.is-loading {
  opacity: 0.85;
}

/* ---------- Acciones de attachments ---------- */
.attachments__actions {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-bottom: var(--space-3);
}

/* ---------- Previews ---------- */
.preview-list {
  list-style: none;
  margin: var(--space-3) 0 0 0;
  padding: 0;
  display: grid;
  gap: var(--space-3);
}

.preview-list--photos {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.preview-list--files {
  grid-template-columns: 1fr;
}

/* Preview de fotos */
.photo-preview {
  position: relative;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.photo-preview__img {
  display: block;
  width: 100%;
  height: 140px;
  object-fit: cover;
  background: #f1f5f9;
}

.photo-preview__info {
  padding: var(--space-2) var(--space-3);
  font-size: 0.8rem;
  color: var(--color-text-muted);
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-2);
  overflow: hidden;
}

.photo-preview__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.photo-preview__remove {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: none;
  background: rgba(15, 23, 42, 0.72);
  color: #fff;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0;
  box-shadow: var(--shadow-sm);
  transition: background 0.15s ease, transform 0.05s ease;
}

.photo-preview__remove:hover,
.photo-preview__remove:focus-visible {
  background: rgba(220, 38, 38, 0.95);
  outline: none;
}

.photo-preview__remove:active {
  transform: scale(0.96);
}

/* Preview de archivos */
.file-preview {
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  box-shadow: var(--shadow-sm);
}

.file-preview__icon {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: #eef2ff;
  color: var(--color-secondary-text);
  font-weight: 700;
  font-size: 0.75rem;
  text-transform: uppercase;
}

.file-preview__body {
  flex: 1 1 auto;
  min-width: 0;
}

.file-preview__name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--color-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-preview__meta {
  margin-top: 2px;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.file-preview__meta .sep {
  display: inline-block;
  margin: 0 6px;
  color: var(--color-text-soft);
}

.file-preview__remove {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--color-danger-border);
  background: var(--color-danger-bg);
  color: var(--color-danger);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  min-height: 40px;
  transition: background 0.15s ease, transform 0.05s ease;
}

.file-preview__remove:hover,
.file-preview__remove:focus-visible {
  background: #fee2e2;
  outline: none;
}

.file-preview__remove:active {
  transform: scale(0.96);
}

/* ---------- Mensajes generales ---------- */
.form-message {
  margin-top: var(--space-5);
  padding: 0;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 500;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: opacity 0.25s ease, max-height 0.25s ease, padding 0.2s ease;
}

.form-message.is-visible {
  padding: var(--space-4);
  max-height: 260px;
  opacity: 1;
}

.form-message--success {
  background: var(--color-success-bg);
  border: 1px solid var(--color-success-border);
  color: var(--color-success);
}

.form-message--error {
  background: var(--color-danger-bg);
  border: 1px solid var(--color-danger-border);
  color: var(--color-danger);
}

.form-message--warning {
  background: var(--color-warning-bg);
  border: 1px solid var(--color-warning-border);
  color: var(--color-warning);
}

.form-message__title {
  margin: 0 0 4px 0;
  font-weight: 700;
}

.form-message__ref {
  display: inline-block;
  margin-top: 8px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(21, 128, 61, 0.12);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  letter-spacing: 0.04em;
}

/* ---------- Modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal[hidden] {
  display: none;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(2px);
  animation: fadeIn 0.18s ease both;
}

.modal__dialog {
  position: relative;
  width: 100%;
  max-width: 480px;
  margin: 0;
  background: #fff;
  border-top-left-radius: var(--radius-lg);
  border-top-right-radius: var(--radius-lg);
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  padding: var(--space-6) var(--space-5) calc(var(--space-6) + env(safe-area-inset-bottom)) var(--space-5);
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.22s ease both;
}

.modal__title {
  margin: 0 0 var(--space-3) 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.3;
}

.modal__desc {
  margin: 0 0 var(--space-6) 0;
  font-size: 0.95rem;
  color: var(--color-text-muted);
  line-height: 1.55;
}

.modal__actions {
  display: flex;
  flex-direction: column-reverse;
  gap: var(--space-3);
}

/* ---------- Animaciones ---------- */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

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

/* ---------- Checkbox privacidad ---------- */
.field--privacy {
  margin-bottom: var(--space-6);
}

.privacy-row {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: 8px 10px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.privacy-checkbox {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  margin: 2px 0 0 0;
  accent-color: var(--color-primary);
  cursor: pointer;
  min-height: 22px;
}

.privacy-label {
  flex: 1 1 auto;
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--color-text);
  cursor: pointer;
  padding-top: 2px;
}

/* Enlace inline dentro del label del checkbox */
.privacy-inline-link {
  display: inline;
  margin: 0 2px;
  padding: 0 1px;
  color: var(--color-primary);
  background: transparent;
  border: 0;
  border-bottom: 1px solid rgba(37, 99, 235, 0.55);
  font-family: inherit;
  font-size: inherit;
  font-weight: 600;
  line-height: inherit;
  text-decoration: none;
  border-radius: 2px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.privacy-inline-link:hover {
  color: #1d4ed8;
  border-bottom-color: #1d4ed8;
  background: rgba(37, 99, 235, 0.07);
}

.privacy-inline-link:focus-visible {
  outline: none;
  color: #1d4ed8;
  background: rgba(37, 99, 235, 0.12);
  border-bottom-color: #1d4ed8;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.22);
}

.privacy-inline-link:active {
  color: #1e40af;
}

.field[data-error="true"] .privacy-inline-link {
  color: var(--color-danger);
  border-bottom-color: rgba(220, 38, 38, 0.7);
}

.field[data-error="true"] .privacy-inline-link:hover,
.field[data-error="true"] .privacy-inline-link:focus-visible {
  background: rgba(220, 38, 38, 0.08);
}

/* Legacy fila separada del enlace (mantenida por si se vuelve a usar) */
.privacy-link-row {
  margin: var(--space-3) 0 0 0;
  padding-left: calc(22px + var(--space-3));
}

.btn-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--color-primary);
  padding: 8px 14px;
  margin: 0;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.2;
  color: var(--color-primary);
  text-decoration: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  min-height: 38px;
  width: auto;
  appearance: none;
  -webkit-appearance: none;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
}

.btn-link:hover,
.btn-link:focus-visible {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
  outline: none;
  text-decoration: none;
}

.btn-link:focus-visible {
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.22);
}

.btn-link:active {
  transform: scale(0.98);
}

/* Estado ERROR del checkbox privacidad: todo en ROJO */
.field[data-error="true"] .privacy-row {
  background: var(--color-danger-bg);
  border-color: var(--color-danger-border);
}

.field[data-error="true"] .privacy-checkbox {
  accent-color: var(--color-danger);
  outline: 2px solid var(--color-danger-border);
  outline-offset: 1px;
  border-radius: 4px;
}

.field[data-error="true"] .privacy-label {
  color: var(--color-danger);
  font-weight: 600;
}

/* ---------- Modal: boton cerrar X ---------- */
.modal__close-x {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 38px;
  height: 38px;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: #fff;
  color: var(--color-text-muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0;
  z-index: 2;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
}

.modal__close-x:hover,
.modal__close-x:focus-visible {
  background: var(--color-danger-bg);
  color: var(--color-danger);
  border-color: var(--color-danger-border);
  outline: none;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.14);
}

.modal__close-x:active {
  transform: scale(0.96);
}

/* Ajuste del titulo en modales con boton X */
.modal__dialog .modal__title {
  padding-right: 48px;
}

/* Modal privacidad: contenido multilinea */
.modal--privacy .modal__desc p {
  margin: 0 0 var(--space-3) 0;
}

.modal--privacy .modal__desc p:last-child {
  margin-bottom: 0;
}

/* ---------- Modal SUCCESS ---------- */
.modal--success .modal__dialog {
  text-align: center;
}

.modal__actions--center {
  justify-content: center;
}

.modal__icon {
  width: 80px;
  height: 80px;
  margin: var(--space-2) auto var(--space-5) auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.modal__icon svg {
  width: 100%;
  height: 100%;
  height: 80px;
  width: 80px;
}

.modal__icon--success {
  color: #15803d;
}

.modal__title--success {
  text-align: center;
  padding-right: 0 !important;
  margin-bottom: var(--space-3);
  font-size: 1.45rem;
  color: var(--color-text);
}

.modal__desc--success {
  text-align: center;
  font-size: 1rem;
  color: var(--color-text-muted);
  margin: 0 0 var(--space-5) 0;
  line-height: 1.55;
}

@media (max-width: 640px) {
  .modal__icon {
    width: 72px;
    height: 72px;
    margin-bottom: var(--space-4);
  }
  .modal__title--success {
    font-size: 1.25rem;
  }
}

/* ============================================================
   PANTALLAS MAS GRANDES (tablet+)
   ============================================================ */
@media (min-width: 640px) {
  .app {
    padding-top: var(--space-8);
  }

  .app__title {
    font-size: 1.9rem;
  }

  .form {
    padding: var(--space-7);
  }

  .modal {
    align-items: center;
  }

  .modal__dialog {
    border-radius: var(--radius-lg);
    padding: var(--space-7);
  }

  .modal__actions {
    flex-direction: row;
    justify-content: flex-end;
  }

  .modal__actions .btn {
    min-width: 160px;
  }
}

/* ============================================================
   BLOQUES TEMPORALMENTE OCULTOS DEL FRONTEND
   (mantenidos en DOM y backend por si se reactivan mas adelante)
   ============================================================ */
.field--is-hidden-from-frontend,
.field--is-hidden-from-frontend * {
  display: none !important;
  visibility: hidden !important;
  width: 0 !important;
  height: 0 !important;
  min-width: 0 !important;
  min-height: 0 !important;
  max-width: 0 !important;
  max-height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
  position: absolute !important;
  left: 0 !important;
  top: 0 !important;
  clip: rect(0 0 0 0) !important;
  clip-path: inset(100%) !important;
  white-space: nowrap !important;
  border: 0 !important;
  outline: 0 !important;
  box-shadow: none !important;
  background: transparent !important;
  color: transparent !important;
  z-index: -1 !important;
}
