/* Popup de contacto (botones "Analizar mi caso"). Se abre con assets/js/contact-popup.js */
html.cp-lock { overflow: hidden; }

dialog.cp-dialog {
  border: 0; padding: 0; margin: auto; inset: 0;
  width: min(440px, calc(100vw - 2rem));
  height: fit-content;
  max-height: calc(100dvh - 1rem);
  border-radius: 12px;
  background: var(--bg-light, #fff);
  color: var(--text-dark, #0f172a);
  box-shadow: 0 30px 80px rgba(15, 23, 42, .28);
  overflow: hidden;
  font-family: inherit;
}
dialog.cp-dialog::backdrop { background: rgba(15, 23, 42, .55); backdrop-filter: blur(3px); }
dialog.cp-dialog[open] { display: flex; flex-direction: column; animation: cp-in .2s ease-out; }
@keyframes cp-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { dialog.cp-dialog[open] { animation: none; } }

.cp-head { position: relative; padding: 2.4rem 3.5rem 0 2.25rem; background: transparent; }
.cp-kicker { display: block; font-size: .7rem; font-weight: 700; letter-spacing: .18em; color: var(--accent-color, #2563eb); margin-bottom: .55rem; }
.cp-head h2 { margin: 0; font-family: 'Montserrat', sans-serif; font-size: 1.35rem; line-height: 1.3; font-weight: 700; color: var(--primary-color, #1e293b); }
.cp-head p { margin: .5rem 0 0; font-size: .9rem; line-height: 1.45; color: var(--text-muted, #475569); }
.cp-close {
  position: absolute; top: 1rem; right: 1rem; width: 2.5rem; height: 2.5rem;
  display: flex; align-items: center; justify-content: center;
  border: 0; border-radius: 50%; background: transparent; color: var(--text-muted, #475569); cursor: pointer;
}
.cp-close:hover, .cp-close:focus-visible { background: #f1f5f9; color: var(--primary-color, #1e293b); }

.cp-body { padding: 1.75rem 2.25rem 2.4rem; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.cp-row { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.cp-field { margin-bottom: 1rem; }
.cp-body input[type="text"], .cp-body input[type="tel"], .cp-body input[type="email"], .cp-body textarea {
  width: 100%; box-sizing: border-box; padding: .85rem 1rem;
  font: inherit; font-size: 1rem; /* 16px: evita el zoom de iOS */
  border: 1px solid #e2e8f0; border-radius: 8px; background: #f8fafc; color: var(--text-dark, #0f172a);
  transition: border-color .15s, background .15s;
}
.cp-body textarea { height: 7.5rem; resize: none; }
.cp-body input:focus, .cp-body textarea:focus { outline: 0; background: #fff; border-color: var(--accent-color, #2563eb); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
.cp-legal { display: flex; gap: .6rem; align-items: flex-start; font-size: .8rem; line-height: 1.4; color: var(--text-muted, #475569); margin: 1.25rem 0; }
.cp-legal input { margin-top: .15rem; flex: none; accent-color: var(--accent-color, #2563eb); }
.cp-legal a { color: var(--primary-color, #1e293b); text-decoration: underline; text-underline-offset: 2px; }
.cp-ts { min-height: 70px; margin-bottom: 1.25rem; display: flex; justify-content: flex-start; }
.cp-actions { display: flex; gap: .6rem; align-items: stretch; }
.cp-submit {
  flex: 1; padding: .95rem 1rem; border: 0; border-radius: 8px;
  background: var(--accent-color, #2563eb); color: #fff;
  font: inherit; font-weight: 700; font-size: .85rem; letter-spacing: .06em; text-transform: uppercase; cursor: pointer;
  transition: background .15s;
}
.cp-submit:hover { background: var(--accent-hover, #1d4ed8); }
.cp-submit:disabled { opacity: .65; cursor: wait; }
.cp-icon {
  flex: none; width: 3.1rem; display: flex; align-items: center; justify-content: center;
  border: 1px solid #e2e8f0; border-radius: 8px; background: #fff; color: var(--primary-color, #1e293b); text-decoration: none;
  transition: border-color .15s, color .15s, background .15s;
}
.cp-icon:hover, .cp-icon:focus-visible { border-color: var(--accent-color, #2563eb); color: var(--accent-color, #2563eb); background: #f8fafc; outline: 0; }
.cp-feedback { display: none; padding: .7rem .9rem; margin-bottom: .9rem; border-radius: 8px; font-weight: 600; font-size: .9rem; text-align: center; }
.cp-feedback.ok { display: block; background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.cp-feedback.err { display: block; background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.cp-hp { position: absolute; left: -5000px; height: 0; overflow: hidden; }
.cp-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Móvil: tarjeta centrada y pequeña que se ajusta a su contenido */
@media (max-width: 600px) {
  dialog.cp-dialog { width: calc(100vw - 2.5rem); max-width: 400px; height: fit-content; max-height: calc(100dvh - 1.5rem); border-radius: 14px; margin: auto; }
  .cp-row { grid-template-columns: 1fr; gap: 0; }
  .cp-head { padding: 1.1rem 3rem 0 1.1rem; }
  .cp-kicker { font-size: .65rem; margin-bottom: .3rem; }
  .cp-head h2 { font-size: 1.05rem; }
  .cp-head p { display: none; }
  .cp-close { top: .45rem; right: .45rem; width: 2.25rem; height: 2.25rem; }
  .cp-body { padding: .8rem 1.1rem 1.1rem; }
  .cp-field { margin-bottom: .5rem; }
  .cp-body input[type="text"], .cp-body input[type="tel"], .cp-body input[type="email"], .cp-body textarea { padding: .6rem .8rem; }
  .cp-body textarea { height: 4.2rem; }
  .cp-legal { margin: .65rem 0; font-size: .75rem; }
  .cp-ts { min-height: 65px; margin-bottom: .65rem; }
  .cp-submit { padding: .7rem 1rem; font-size: .8rem; }
  .cp-icon { width: 2.8rem; }
}

/* Ajuste por altura de pantalla: que todo quepa sin deslizar */
@media (min-width: 601px) and (max-height: 739px) {
  .cp-head { padding: 1.4rem 3.5rem 0 1.75rem; }
  .cp-head p { display: none; }
  .cp-kicker { margin-bottom: .35rem; }
  .cp-head h2 { font-size: 1.2rem; }
  .cp-body { padding: 1.1rem 1.75rem 1.5rem; }
  .cp-field { margin-bottom: .65rem; }
  .cp-body input[type="text"], .cp-body input[type="tel"], .cp-body input[type="email"], .cp-body textarea { padding: .7rem .9rem; }
  .cp-body textarea { height: 6.2rem; }
  .cp-field { margin-bottom: .8rem; }
  .cp-legal { margin: .9rem 0; }
  .cp-ts { margin-bottom: .7rem; }
  .cp-submit { padding: .8rem 1rem; }
}
@media (min-width: 601px) and (max-height: 619px) {
  .cp-head { padding-top: 1rem; }
  .cp-body { padding-top: .75rem; padding-bottom: 1rem; }
  .cp-body textarea { height: 3.6rem; }
  .cp-field { margin-bottom: .45rem; }
  .cp-legal { margin: .5rem 0; }
  .cp-ts { margin-bottom: .5rem; }
}

/* Pantallas altas: más altura y más aire */
@media (min-width: 601px) and (min-height: 900px) {
  dialog.cp-dialog { width: min(480px, calc(100vw - 2rem)); }
  .cp-head { padding-top: 3rem; }
  .cp-kicker { margin-bottom: .75rem; }
  .cp-head h2 { font-size: 1.45rem; }
  .cp-head p { margin-top: .7rem; }
  .cp-body { padding: 2.25rem 2.5rem 3rem; }
  .cp-head { padding-left: 2.5rem; }
  .cp-field { margin-bottom: 1.25rem; }
  .cp-row { gap: 1rem; }
  .cp-body input[type="text"], .cp-body input[type="tel"], .cp-body input[type="email"], .cp-body textarea { padding: 1rem 1.1rem; }
  .cp-body textarea { height: 10rem; }
  .cp-legal { margin: 1.5rem 0; }
  .cp-ts { margin-bottom: 1.5rem; }
  .cp-submit { padding: 1.1rem 1rem; }
  .cp-icon { width: 3.4rem; }
}

/* Ordenador: popup grande que aprovecha la altura disponible; el mensaje se estira */
@media (min-width: 601px) {
  dialog.cp-dialog { width: min(450px, calc(100vw - 3rem)); height: min(calc(100dvh - 3rem), 940px); }
  .cp-body input[type="text"], .cp-body input[type="tel"], .cp-body input[type="email"], .cp-body textarea { padding-left: .9rem; padding-right: .9rem; }
  .cp-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
  .cp-body form { display: flex; flex-direction: column; flex: 1; min-height: 0; }
  .cp-grow { flex: 1; display: flex; flex-direction: column; min-height: 4rem; }
  .cp-grow textarea { flex: 1; height: auto; min-height: 3rem; }
  .cp-head h2 { font-size: 1.5rem; }
}

/* Toques premium sutiles (no cambian medidas) */
dialog.cp-dialog {
  border: 1px solid rgba(15, 23, 42, .06);
  box-shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 12px 32px rgba(15, 23, 42, .14), 0 40px 90px rgba(15, 23, 42, .22);
}
dialog.cp-dialog::backdrop { background: radial-gradient(ellipse at center, rgba(15, 23, 42, .5), rgba(15, 23, 42, .66)); backdrop-filter: blur(4px); }
dialog.cp-dialog[open] { animation: cp-in .28s cubic-bezier(.2, .8, .2, 1); }
@keyframes cp-in { from { opacity: 0; transform: translateY(14px) scale(.985); } to { opacity: 1; transform: none; } }
.cp-head::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--primary-color, #1e293b), var(--accent-color, #2563eb) 60%, #60a5fa);
}
.cp-kicker { display: flex; align-items: center; gap: .6rem; }
.cp-kicker::before { content: ''; width: 1.25rem; height: 1px; background: currentColor; opacity: .7; }
.cp-head h2 { letter-spacing: -.01em; }
.cp-close { transition: background .2s, color .2s, transform .25s; }
.cp-close:hover { transform: rotate(90deg); }
.cp-body input[type="text"], .cp-body input[type="tel"], .cp-body input[type="email"], .cp-body textarea {
  border-color: #e5eaf1; background: #f9fafc; transition: border-color .2s, background .2s, box-shadow .2s;
}
.cp-body input:hover:not(:focus), .cp-body textarea:hover:not(:focus) { border-color: #cfd8e3; }
.cp-body input:focus, .cp-body textarea:focus { box-shadow: 0 0 0 4px rgba(37, 99, 235, .10), 0 1px 2px rgba(15, 23, 42, .05); }
.cp-submit {
  background: linear-gradient(180deg, #2f6df0, var(--accent-color, #2563eb) 55%, #1f56d6);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .18) inset, 0 6px 16px rgba(37, 99, 235, .28);
  transition: transform .2s, box-shadow .2s, filter .2s;
}
.cp-submit:hover:not(:disabled) { transform: translateY(-1px); filter: brightness(1.06); box-shadow: 0 1px 0 rgba(255, 255, 255, .2) inset, 0 10px 22px rgba(37, 99, 235, .34); }
.cp-submit:active:not(:disabled) { transform: none; }
.cp-icon { box-shadow: 0 1px 2px rgba(15, 23, 42, .04); transition: border-color .2s, color .2s, background .2s, transform .2s, box-shadow .2s; }
.cp-icon:hover, .cp-icon:focus-visible { transform: translateY(-1px); box-shadow: 0 6px 14px rgba(15, 23, 42, .08); }
@media (prefers-reduced-motion: reduce) {
  dialog.cp-dialog[open], .cp-close, .cp-submit, .cp-icon { animation: none; transition: none; }
  .cp-close:hover, .cp-submit:hover, .cp-icon:hover { transform: none; }
}
