/* Asistente con IA de CodeDatas: lanzador, globo de invitación y panel de chat */
.fab { border: 0; font: inherit; cursor: pointer; }
.fab-dot { width: 8px; height: 8px; margin-left: 2px; border-radius: 50%; background: #3ac28b; animation: fabping 2.6s infinite; }
@keyframes fabping { 0% { box-shadow: 0 0 0 0 rgba(58,194,139,.6); } 70%, 100% { box-shadow: 0 0 0 8px rgba(58,194,139,0); } }
@media (max-width: 600px) { .fab-dot { position: absolute; top: 9px; right: 9px; } }
html.cd-chat-open .fab { opacity: 0 !important; pointer-events: none; visibility: hidden; }

/* Globo de invitación */
.cd-teaser {
    position: fixed; right: 28px; bottom: calc(92px + var(--fab-lift, 0px)); z-index: 41; max-width: 250px;
    background: #fff; color: var(--ink); border: 1px solid var(--line-2); border-radius: 14px 14px 4px 14px;
    padding: 12px 34px 12px 14px; font-size: 13.5px; line-height: 1.45;
    box-shadow: 0 18px 40px -14px rgba(6,13,31,.35);
    opacity: 0; transform: translateY(8px) scale(.98); pointer-events: none; visibility: hidden;
    transition: opacity .3s, transform .35s var(--ease), visibility 0s linear .35s;
}
.cd-teaser.is-show { opacity: 1; transform: none; pointer-events: auto; visibility: visible; transition-delay: 0s; }
.cd-teaser a { display: block; color: inherit; }
.cd-teaser strong { color: var(--accent); font-weight: 600; }
.cd-teaser button { position: absolute; top: 6px; right: 6px; width: 24px; height: 24px; border: 0; background: none; font-size: 18px; line-height: 1; color: var(--ink-3); border-radius: 6px; cursor: pointer; }
.cd-teaser button:hover { background: var(--tint); color: var(--ink); }
@media (max-width: 600px) { .cd-teaser { right: 16px; bottom: calc(108px + var(--fab-lift, 0px)); } }

/* Contenedor */
.cd-chat { position: fixed; right: 24px; bottom: calc(24px + var(--fab-lift, 0px)); z-index: 80; width: min(396px, calc(100vw - 32px)); }
.cd-chat[hidden] { display: none; }
.cd-panel {
    display: flex; flex-direction: column; height: min(640px, calc(100dvh - 96px - var(--fab-lift, 0px))); min-height: 420px;
    background: #fff; border: 1px solid rgba(13,20,36,.1); border-radius: 22px; overflow: hidden;
    box-shadow: 0 40px 90px -24px rgba(6,13,31,.55), 0 0 0 1px rgba(255,255,255,.5) inset;
    opacity: 0; transform: translateY(16px) scale(.97); transform-origin: 100% 100%;
    transition: opacity .25s, transform .3s var(--ease);
}
.cd-chat.is-open .cd-panel { opacity: 1; transform: none; }

/* Cabecera */
.cd-head { display: flex; align-items: center; gap: 10px; padding: 14px 14px 14px 16px; color: #fff; position: relative;
    background: radial-gradient(120% 140% at 100% 0%, rgba(60,140,255,.45), transparent 60%), linear-gradient(135deg, #0a1736, #0d2257); }
.cd-head-av { flex: none; width: 40px; height: 40px; border-radius: 50%; overflow: hidden; background: #fff; box-shadow: 0 0 0 2px rgba(255,255,255,.3); }
.cd-head-av img { width: 100%; height: 100%; display: block; }
.cd-head-t { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.cd-head-t strong { font-size: 15px; font-weight: 600; letter-spacing: -.01em; }
.cd-head-t span { font-size: 12px; color: #b4c3e6; display: inline-flex; align-items: center; gap: 6px; }
.cd-live { width: 7px; height: 7px; border-radius: 50%; background: #3ac28b; box-shadow: 0 0 0 0 rgba(58,194,139,.6); animation: fabping 2.6s infinite; }
.cd-iconbtn { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border: 0; border-radius: 10px; background: rgba(255,255,255,.1); color: #fff; cursor: pointer; transition: background .2s; }
.cd-iconbtn:hover { background: rgba(255,255,255,.22); }

/* Cuerpo */
.cd-body { flex: 1; overflow-y: auto; padding: 18px 16px 8px; background: linear-gradient(180deg, #f7f8fb, #fff 40%); scroll-behavior: smooth; overscroll-behavior: contain; }
.cd-msg { display: flex; gap: 8px; margin-bottom: 12px; align-items: flex-end; animation: cdin .35s var(--ease) both; }
@keyframes cdin { from { opacity: 0; transform: translateY(8px); } }
.cd-usuario { justify-content: flex-end; }
.cd-av { flex: none; width: 26px; height: 26px; border-radius: 50%; background: url('../img/logo-96.png') center / cover #fff; box-shadow: 0 0 0 1px var(--line-2); }
.cd-bub { max-width: 84%; padding: 10px 14px; font-size: 14.5px; line-height: 1.55; border-radius: 16px; overflow-wrap: anywhere; }
.cd-asistente .cd-bub { background: #fff; color: var(--ink); border: 1px solid var(--line); border-bottom-left-radius: 5px; box-shadow: 0 1px 2px rgba(13,20,36,.04); }
.cd-usuario .cd-bub { background: linear-gradient(135deg, #1668e3, #1f3fd1); color: #fff; border-bottom-right-radius: 5px; box-shadow: 0 6px 16px -8px rgba(22,104,227,.7); }
.cd-bub p { margin: 0; } .cd-bub p + p, .cd-bub p + ul, .cd-bub ul + p { margin-top: 8px; }
.cd-bub ul { margin: 0; padding-left: 18px; list-style: disc; } .cd-bub li { margin: 3px 0; }
.cd-bub strong { font-weight: 600; }
.cd-live-text::after { content: ''; display: inline-block; width: 7px; height: 14px; margin-left: 3px; vertical-align: -2px; border-radius: 2px; background: var(--accent); animation: cdblink 1s steps(2) infinite; }
@keyframes cdblink { 50% { opacity: 0; } }
.cd-err { background: #fff7f5 !important; border-color: #f5c9c0 !important; color: #8a2c1c !important; }
.cd-inline { margin-top: 10px; }
.cd-dots { display: inline-flex; gap: 4px; padding: 4px 2px; }
.cd-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); animation: cddot 1.2s infinite ease-in-out; }
.cd-dots i:nth-child(2) { animation-delay: .15s; } .cd-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes cddot { 0%, 80%, 100% { transform: scale(.6); opacity: .4; } 40% { transform: scale(1); opacity: 1; } }

/* Bienvenida */
.cd-welcome { text-align: center; padding: 6px 2px 10px; animation: cdin .45s var(--ease) both; }
.cd-welcome-av { display: block; width: 64px; height: 64px; margin: 4px auto 12px; border-radius: 50%; background: url('../img/logo.png') center / cover #fff; box-shadow: 0 0 0 1px var(--line-2), 0 12px 28px -10px rgba(22,104,227,.5); }
.cd-welcome h3 { margin: 0; font-size: 18px; letter-spacing: -.02em; font-weight: 600; }
.cd-welcome p { margin: 8px auto 16px; max-width: 28em; font-size: 14px; color: var(--ink-2); }
.cd-sectors { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; text-align: left; }
.cd-sector { padding: 12px 12px; background: #fff; border: 1px solid var(--line-2); border-radius: 12px; cursor: pointer; font: inherit; font-size: 13.5px; color: var(--ink); transition: border-color .2s, transform .2s var(--ease), box-shadow .2s; }
.cd-sector:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 10px 22px -12px rgba(22,104,227,.5); }
.cd-sector strong { font-weight: 600; }
.cd-others { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 12px; }

/* Tarjetas de sistema */
.cd-rail { display: flex; gap: 10px; overflow-x: auto; margin: 0 -16px 12px; padding: 2px 16px 6px 42px; scroll-snap-type: x proximity; scrollbar-width: none; animation: cdin .4s var(--ease) both; }
.cd-rail::-webkit-scrollbar { display: none; }
.cd-card { flex: none; width: 236px; scroll-snap-align: start; background: #fff; border: 1px solid var(--line-2); border-radius: 14px; overflow: hidden; box-shadow: 0 8px 22px -14px rgba(6,13,31,.35); }
.cd-cover { position: relative; height: 70px; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 24px; font-weight: 600; letter-spacing: -.02em; background: linear-gradient(135deg, #0a1736, #1650c4); }
.cd-cover.cd-p1 { background: linear-gradient(135deg, #0b1f3d, #0e7490); } .cd-cover.cd-p2 { background: linear-gradient(135deg, #111a3a, #4338ca); }
.cd-cover.cd-p3 { background: linear-gradient(135deg, #0a1736, #0f766e); } .cd-cover.cd-p4 { background: linear-gradient(135deg, #0d1424, #334a7a); }
.cd-cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: top; }
.cd-card-body { padding: 12px 12px 12px; display: flex; flex-direction: column; gap: 3px; }
.cd-card-body strong { font-size: 15px; letter-spacing: -.01em; }
.cd-card-body small { font-size: 12px; color: var(--ink-3); line-height: 1.35; }
.cd-prices { display: flex; gap: 14px; margin: 8px 0 10px; font-size: 14px; font-weight: 600; }
.cd-prices i { display: block; font: 500 10px/1.4 var(--mono); letter-spacing: .05em; text-transform: uppercase; color: var(--ink-3); font-style: normal; }
.cd-card-actions { display: flex; gap: 6px; }
.cd-btn { flex: 1; display: inline-flex; align-items: center; justify-content: center; padding: 9px 10px; font-size: 13px; font-weight: 500; border-radius: 9px; border: 1px solid transparent; cursor: pointer; text-decoration: none; transition: background .2s, border-color .2s; }
.cd-btn-line { background: #fff; border-color: var(--line-2); color: var(--ink); } .cd-btn-line:hover { border-color: var(--ink); }
.cd-btn-solid { background: var(--accent); color: #fff; } .cd-btn-solid:hover { background: var(--accent-ink); }
.cd-inline { display: inline-flex; flex: none; }

/* Sugerencias */
.cd-sugg { display: flex; gap: 6px; overflow-x: auto; padding: 4px 16px 0; scrollbar-width: none; background: #fff; }
.cd-sugg:empty { display: none; }
.cd-sugg::-webkit-scrollbar { display: none; }
.cd-chip { flex: none; padding: 8px 13px; font: inherit; font-size: 13px; color: var(--accent-ink); background: #eef3ff; border: 1px solid #d3e0fb; border-radius: 999px; cursor: pointer; transition: background .2s, border-color .2s; white-space: nowrap; }
.cd-chip:hover { background: #e0eaff; border-color: var(--accent); }

/* Compositor */
.cd-form { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px 6px; background: #fff; }
.cd-form textarea { flex: 1; min-height: 44px; max-height: 110px; resize: none; padding: 12px 14px; font: inherit; font-size: 14.5px; line-height: 1.4; color: var(--ink); background: var(--tint); border: 1px solid transparent; border-radius: 14px; outline: none; transition: border-color .2s, background .2s, box-shadow .2s; }
.cd-form textarea:focus { background: #fff; border-color: var(--accent); box-shadow: 0 0 0 4px rgba(22,104,227,.12); }
.cd-send, .cd-mic { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border: 0; border-radius: 14px; cursor: pointer; transition: background .2s, transform .15s; }
.cd-send { background: var(--accent); color: #fff; } .cd-send:hover { background: var(--accent-ink); } .cd-send:active { transform: scale(.94); }
.cd-send .i-stop { display: none; } .is-busy .cd-send .i-send { display: none; } .is-busy .cd-send .i-stop { display: block; } .is-busy .cd-send { background: var(--ink); }
.cd-mic { background: var(--tint); color: var(--ink-2); } .cd-mic:hover { background: #e7e8e2; }
.cd-mic[hidden] { display: none; }
.cd-mic.is-rec { background: #fde8e4; color: #c5301a; animation: fabping 1.6s infinite; box-shadow: 0 0 0 0 rgba(197,48,26,.4); }
.cd-foot { margin: 0; padding: 4px 16px 12px; font-size: 11px; line-height: 1.4; color: var(--ink-3); text-align: center; background: #fff; }
.cd-foot a { text-decoration: underline; text-underline-offset: 2px; }

:focus-visible { outline-offset: 2px; }

/* Móvil: hoja a pantalla completa */
@media (max-width: 600px) {
    .cd-chat { inset: 0; width: auto; }
    .cd-panel { height: 100dvh; min-height: 0; border-radius: 0; border: 0; transform: translateY(24px); }
    .cd-head { padding-top: calc(14px + env(safe-area-inset-top, 0px)); }
    .cd-foot { padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }
    .cd-bub { max-width: 88%; font-size: 15px; }
    .cd-card { width: 224px; }
    .cd-iconbtn { width: 40px; height: 40px; }
    .cd-form textarea { font-size: 16px; } /* evita el zoom automático en iOS */
}
html.cd-chat-open.cd-lock, html.cd-chat-open body { overscroll-behavior: contain; }
@media (max-width: 600px) { html.cd-chat-open body { overflow: hidden; } }

@media (prefers-reduced-motion: reduce) {
    .cd-panel, .cd-msg, .cd-welcome, .cd-rail { animation: none !important; transition: none !important; }
    .cd-live, .fab-dot, .cd-live-text::after { animation: none !important; }
}
.cd-head-t strong, .cd-head-t span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 600px) { .cd-iconbtn { width: 38px; height: 38px; } .cd-head { gap: 8px; } }

/* Consentimiento y contacto */
.cd-consent { display: flex; align-items: flex-start; gap: 8px; margin: 0; padding: 8px 16px 0; background: #fff; font-size: 11.5px; line-height: 1.4; color: var(--ink-2); cursor: pointer; }
.cd-consent input { flex: none; width: 15px; height: 15px; margin-top: 1px; accent-color: var(--accent); cursor: pointer; }
.cd-consent a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.cd-leadbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 8px 12px 0; padding: 9px 10px 9px 14px; font-size: 12.5px; color: var(--ink-2); background: linear-gradient(135deg, #eef3ff, #f7f9ff); border: 1px solid #d3e0fb; border-radius: 12px; }
.cd-leadbar[hidden] { display: none; }
.cd-leadbar button { flex: none; padding: 7px 12px; font: inherit; font-size: 12.5px; font-weight: 600; color: #fff; background: var(--accent); border: 0; border-radius: 9px; cursor: pointer; }
.cd-leadbar button:hover { background: var(--accent-ink); }
.cd-lead { width: 100%; max-width: 92%; padding: 14px; background: #fff; border: 1px solid var(--line-2); border-radius: 16px 16px 16px 5px; box-shadow: 0 10px 26px -16px rgba(6,13,31,.4); }
.cd-lead strong { display: block; font-size: 15px; letter-spacing: -.01em; }
.cd-lead > p { margin: 4px 0 10px; font-size: 13px; color: var(--ink-2); line-height: 1.45; }
.cd-lead label { display: block; margin-bottom: 8px; font-size: 12px; font-weight: 500; color: var(--ink-2); }
.cd-lead label em { font-style: normal; font-weight: 400; color: var(--ink-3); }
.cd-lead input[type=text], .cd-lead input[type=email], .cd-lead input[type=tel] { display: block; width: 100%; margin-top: 3px; padding: 10px 12px; font: inherit; font-size: 14px; color: var(--ink); background: var(--tint); border: 1px solid transparent; border-radius: 10px; outline: none; }
.cd-lead input:focus { background: #fff; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(22,104,227,.12); }
.cd-lead .cd-check { display: flex; gap: 8px; align-items: flex-start; margin: 4px 0 8px; font-size: 11.5px; font-weight: 400; line-height: 1.4; cursor: pointer; }
.cd-lead .cd-check input { flex: none; width: 15px; height: 15px; margin-top: 1px; accent-color: var(--accent); }
.cd-lead .cd-check a { color: var(--accent); text-decoration: underline; }
.cd-hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.cd-lead-err { margin: 0 0 8px !important; font-size: 12.5px !important; color: #c5301a !important; }
.cd-lead-err[hidden] { display: none; }
.cd-lead-actions { display: flex; gap: 8px; }
.cd-lead-actions .cd-btn { padding: 10px; font-size: 13.5px; }
.cd-lead-actions .cd-btn[disabled] { opacity: .6; cursor: default; }
@media (max-width: 600px) { .cd-lead { max-width: 96%; } .cd-lead input[type=text], .cd-lead input[type=email], .cd-lead input[type=tel] { font-size: 16px; } }
