/* =========================================
   BASE / LAYOUT GENERAL
========================================= */

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

body {
  margin: 0;
  font-family: "Poppins", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background-color: #f6f6f6;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 100vh;
  padding: 40px 0;
}

/* Contenedor principal del formulario */
.container {
  background-color: #ffffff;
  padding: 60px 80px;
  border-radius: 24px;
  box-shadow: 0 3px 20px rgba(0, 0, 0, 0.08);
  width: 720px;
  max-width: 92vw;
  box-sizing: border-box;
  margin: 32px auto;
  animation: fadeInScale 0.7s ease-out both;
}

.title-main {
  text-align: center;
  margin-bottom: 4px !important;
}

.title-sub {
  text-align: center;
  margin-top: 4px;
  font-size: 14px !important;
  font-weight: 400 !important;
  font-style: italic;
  color: #7a6c61;
  opacity: 0.9;
}


/* Título */
h1 {
  text-align: center;
  color: #7a6c61;
  font-size: 28px;
  margin-bottom: 40px;
}


.title-main {
  text-align: center;
  color: #7a6c61;
  font-size: 28px;
  margin-bottom: 24px;
  font-weight: 700;
}

.title-sub {
  margin-top: 4px;
  font-size: 14px;
  font-weight: 400;   /* sin negrita */
  color: #7a6c61;
}


/* Etiquetas */
label,
.field label {
  display: block;
  margin-top: 22px;
  font-weight: 600;
  color: #5a4c3f;
  font-size: 15px;
}

/* Inputs / selects / textarea */
input,
select,
textarea,
.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 12px 14px;
  margin-top: 8px;
  border: 1px solid #decac0;
  border-radius: 10px;
  outline: none;
  font-family: inherit;
  font-size: 15px;
  background: #fff;
  appearance: none;
  transition: all 0.25s ease;
}

input:focus,
select:focus,
textarea:focus,
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: #bca89f;
  box-shadow: 0 0 0 3px rgba(188, 168, 159, 0.15);
}

/* Grid del formulario */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 24px;
  width: 100%;
}

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

/* Filas legacy */
.row {
  display: flex;
  gap: 36px;
  margin-bottom: 20px;
}

/* =========================================
   CAMPO TELÉFONO / WHATSAPP
========================================= */

.phone-field {
  display: flex;
  align-items: stretch;
  gap: 8px;
  margin-top: 8px;
  position: relative;
}

.phone-field input[type="tel"] {
  flex: 1;
  margin-top: 0; /* anulamos el margin-top genérico para que alinee con el botón */
}

.phone-country-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid #decac0;
  background: #fff8f4;
  font-size: 14px;
  color: #5a4c3f;
  cursor: pointer;
  white-space: nowrap;
  min-width: 90px;
  height: 44px;
}

.phone-country-btn:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(188, 168, 159, 0.25);
}

#phoneCountryFlag {
  font-size: 18px;
}

.phone-chevron {
  font-size: 10px;
  opacity: 0.7;
  margin-left: 4px;
}

/* Dropdown de países */
.phone-country-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 4px;
  width: 260px;
  max-height: 260px;
  background: #ffffff;
  border-radius: 12px;
  border: 1px solid #decac0;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.12);
  z-index: 50;
  overflow: hidden;
}

.phone-country-search {
  width: 100%;
  padding: 8px 10px;
  border: none;
  border-bottom: 1px solid #f0e7e3;
  font-size: 14px;
  outline: none;
}

.phone-country-list {
  list-style: none;
  margin: 0;
  padding: 4px 0;
  max-height: 210px;
  overflow-y: auto;
}

.phone-country-item {
  padding: 6px 10px;
  font-size: 14px;
  color: #4d4037;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
}

.phone-country-item:hover {
  background: #fff7f2;
}

/* =========================================
   ÁREA DE CARGA DE IMAGEN
========================================= */

.upload-area {
  width: 100%;
  min-height: 140px;
  margin-top: 25px;
  border: 2px dashed #decac0;
  border-radius: 12px;
  background: #fffaf7;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
  padding: 40px 16px;
  text-align: center;
  color: #8c7b70;
  font-size: 15px;
  transition: all 0.3s ease;
}

.upload-area:hover {
  background-color: #fdf4ef;
}

.upload-area.drag-over {
  border-color: #bca89f;
  background-color: #fdf4ef;
}

.upload-area p#uploadText {
  margin: 0;
  line-height: 1.4;
}

/* Vista previa */
#imagePreview,
.upload-area img#imagePreview {
  width: 100%;
  max-height: 260px;
  border-radius: 12px;
  object-fit: cover;
  margin-top: 15px;
  display: none;
  animation: fadeIn 0.4s ease-in-out;
}

/* Nombre de archivo */
.file-name {
  display: none;
  margin-top: 8px;
  font-size: 0.9rem;
  color: #555;
  font-style: italic;
  word-break: break-word;
  max-width: 100%;
}

/* Botón eliminar imagen */
.remove-image,
.upload-area .remove-image {
  display: none;
  justify-content: center;
  align-items: center;
  position: absolute;
  top: 12px;
  right: 12px;
  width: 28px;
  height: 28px;
  background-color: #bca89f;
  color: white;
  border-radius: 50%;
  cursor: pointer;
  font-weight: bold;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

/* =========================================
   BOTÓN PRINCIPAL / ACCIONES
========================================= */

button {
  font-family: inherit;
}

.actions {
  grid-column: 1 / -1;
}

.actions button[type="submit"],
button.primary-submit {
  width: 100%;
  padding: 16px;
  border: none;
  background-color: #bca89f;
  color: #ffffff;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
  font-size: 16px;
  transition: background-color 0.3s ease, filter 0.15s ease;
  margin-top: 40px;
}

.actions button[type="submit"]:hover,
button.primary-submit:hover {
  background-color: #a99287;
  filter: brightness(0.95);
}

/* =========================================
   MENSAJES DE ERROR / FLASH
========================================= */

.error-message {
  background: #fff9f3;
  border: 1px solid #e3c8b2;
  border-radius: 8px;
  padding: 6px 12px;
  margin-top: 6px;
  color: #6b4f3f;
  font-size: 13px;
  opacity: 1;
  transition: opacity 0.8s ease;
  animation: fadeInDown 0.4s ease;
}

/* Flash genérico */
.flash-message {
  margin: 12px 0;
  padding: 10px 12px;
  border-radius: 8px;
  transition: opacity 0.6s;
  position: relative;
}

.flash-message.success {
  background: #eaf7ea;
  color: #276738;
}

.flash-message.error {
  background: #fdeaea;
  color: #8a1a1a;
}

.flash-message.fatal {
  background-color: #ffe0e0;
  border: 1px solid #e53935;
  color: #c62828;
}

.flash-close-btn {
  position: absolute;
  top: 8px;
  right: 10px;
  border: none;
  background: transparent;
  font-size: 16px;
  cursor: pointer;
  color: inherit;
}

.flash-close-btn:hover {
  opacity: 0.7;
}

/* =========================================
   OVERLAY DE CARGA
========================================= */

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  animation: fadeInOverlay 0.3s ease;
}

.loading-card {
  background: #fff;
  padding: 24px;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
  text-align: center;
  min-width: 260px;
  color: #7a6c61;
  animation: popIn 0.4s ease;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid #eee;
  border-top-color: #c9ab9f;
  border-radius: 50%;
  margin: 0 auto 12px;
  animation: spin 1s linear infinite;
}

/* =========================================
   TOGGLE MÁSCARA
========================================= */

.toggle {
  display: flex;
  align-items: center;
  gap: 10px;
}

.switch {
  position: relative;
  display: inline-block;
  width: 52px;
  height: 28px;
}

.switch input {
  display: none;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #e5d5cf;
  border-radius: 999px;
  transition: 0.2s;
}

.slider::before {
  content: "";
  position: absolute;
  height: 22px;
  width: 22px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 999px;
  transition: 0.2s;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
}

input:checked + .slider {
  background: #c9ab9f;
}

input:checked + .slider::before {
  transform: translateX(24px);
}

#maskField {
  display: none;
}

#maskField.show {
  display: block;
}

/* =========================================
   CHIPS DE PALETA
========================================= */

.palette-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 12px;
  border: 1.5px solid #d9c6bb;
  border-radius: 12px;
  background: #fff8f4;
  position: relative;
}

.palette-chip .swatch {
  width: 16px;
  height: 16px;
  border-radius: 6px;
  border: 1.4px solid rgba(0, 0, 0, 0.18);
}

.palette-chip .chip-close {
  margin-left: auto;
  align-self: center;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  border: none;
  background: #d0b2a5;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

/* =========================================
   MODALES (PALETAS + POLÍTICAS)
========================================= */

.modal-root,
.palette-modal {
  position: fixed;
  inset: 0;
  z-index: 9998;
  display: none;
  align-items: center;
  justify-content: center;
}

.modal-root.open,
.palette-modal.open {
  display: flex;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(2px);
}

.modal-card {
  position: relative;
  z-index: 1;
  max-width: 880px;
  width: 90%;
  max-height: calc(100vh - 32px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
  padding: 0 0 14px 0;
  display: flex;
  flex-direction: column;
  margin: 16px;
  animation: modalPop 0.25s ease-out;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid #f0e7e3;
}

.modal-title {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 800;
  color: #5a4c3f;
}

.close-btn,
.modal-close {
  border: 0;
  background: #e5c6b9;
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.12);
}

.modal-body {
  padding: 16px 18px 8px;
  flex: 1 1 auto;
  overflow-y: auto;
}

.modal-footer {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  padding: 14px 20px;
  border-top: 1px solid #efdfd7;
}

.modal-btn,
.btn-primary,
.btn-ghost {
  padding: 12px 14px;
  border-radius: 10px;
  border: 0;
  cursor: pointer;
  font-weight: 600;
}

.modal-btn.secondary,
.btn-ghost {
  background: #fff;
  border: 1.5px solid #d9c6bb;
  color: #573b31;
}

.modal-btn.primary,
.btn-primary {
  background: #c9ab9f;
  color: #fff;
}

.modal-btn.primary:disabled,
.btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* =========================================
   CONTENIDO MODAL DE PALETAS
========================================= */

.palette-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn {
  padding: 9px 12px;
  border-radius: 10px;
  cursor: pointer;
  border: 1.5px solid #d9c6bb;
  background: #fff;
  color: #573b31;
  width: 100%;
}

.btn:hover {
  filter: brightness(0.96);
}

.palette-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.palette-card {
  border: 1.5px solid #d9c6bb;
  border-radius: 14px;
  padding: 14px;
  background: #fff8f4;
  cursor: pointer;
  text-align: left;
  transition: box-shadow 0.15s, border-color 0.15s, transform 0.06s;
}

.palette-card:hover {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
  border-color: #c9ab9f;
  transform: translateY(-1px);
}

.palette-card[aria-selected="true"],
.palette-card.selected {
  outline: 3px solid #c9ab9f;
  outline-offset: 1px;
}

.palette-title {
  font-weight: 700;
  margin-bottom: 8px;
  color: #5d4a42;
}

.palette-desc {
  color: #6f635e;
  font-size: 0.92rem;
}

.swatch-row {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.swatch {
  width: 30px;
  height: 22px;
  border-radius: 6px;
  border: 1.8px solid rgba(0, 0, 0, 0.18);
}

/* =========================================
   POLÍTICA DE DATOS
========================================= */

.policy-text-row {
  font-size: 0.9rem;
  color: #6b5a4d;
  line-height: 1.5;
}

.policy-link-btn {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  color: #6b4a3a;
  text-decoration: underline;
  cursor: pointer;
}

.policy-accepted-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: #276738;
  background: #eaf7ea;
  border-radius: 999px;
  padding: 4px 10px;
  margin-top: 6px;
}

.policy-scroll {
  max-height: 360px;
  overflow-y: auto;
  padding-right: 4px;
  font-size: 0.93rem;
  color: #5b4b40;
  line-height: 1.5;
}

.flag-emoji {
  text-transform: none !important;
}

.mask-section {
  display: none !important;
}

.powered-by {
  margin-top: 12px;
  font-size: 12px;
  color: #998a80;
  font-weight: 300;
  text-align: left;
}



/* =========================================
   ANIMACIONES
========================================= */

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

@keyframes fadeInOverlay {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes popIn {
  from {
    transform: scale(0.9);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes fadeInScale {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

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

@keyframes modalPop {
  from {
    transform: scale(0.97);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* =========================================
   RESPONSIVE
========================================= */

@media (max-width: 640px) {
  .form-grid {
    grid-template-columns: 1fr;
  }

  .container {
    padding: 32px 20px;
  }

  .phone-country-dropdown {
    width: 100%;
  }
}
