/* ISA te atiende: chat móvil con aspecto de mensajería. */
:root {
    --isa-head: #0B4A43;
    --isa-head-sub: #D6EDE8;
    --isa-wall: #EFEAE2;
    --isa-in: #FFFFFF;
    --isa-out: #D9FDD3;
    --isa-ink: #111B21;
    --isa-ink-2: #3B4A54;
    --isa-meta: #667781;
    --isa-line: #E9EDEF;
    --isa-accent: #00695A;
    --isa-read: #1D8FCF;
    --isa-shadow: 0 1px 0.5px rgba(11, 20, 26, 0.13);
    --isa-font: -apple-system, system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--isa-wall); }
body {
    font-family: var(--isa-font);
    color: var(--isa-ink);
    -webkit-text-size-adjust: 100%;
    overscroll-behavior: none;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.isa-sr {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap;
}
.isa-noscript { padding: 24px; font-size: 16px; }

.isa-app {
    position: relative;
    height: 100vh;
    height: 100dvh;
    max-width: 720px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    background: var(--isa-wall);
    overflow: hidden;
}
@media (min-width: 721px) {
    body { background: #D8D3CB; }
    .isa-app { box-shadow: 0 0 24px rgba(0, 0, 0, 0.12); }
}

/* Cabecera */
.isa-header {
    position: relative;
    flex-shrink: 0;
    height: 64px;
    padding: env(safe-area-inset-top) 8px 0 4px;
    box-sizing: content-box;
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--isa-head);
    color: #FFFFFF;
}
.isa-icon-btn {
    width: 44px; height: 44px; flex-shrink: 0;
    border: 0; background: transparent; color: inherit;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%; text-decoration: none;
}
.isa-icon-btn:focus-visible, .isa-send:focus-visible, .isa-quick-btn:focus-visible { outline: 2px solid #7FD4C4; outline-offset: 2px; }
.isa-muted { color: #54656F; }
.isa-avatar {
    width: 40px; height: 40px; flex-shrink: 0; border-radius: 50%;
    background-color: #F4E6D8;
    background-repeat: no-repeat;
    background-size: 181.6% auto;
    background-position: 43.5% 5.6%;
}
.isa-title { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.isa-name { font-size: 17px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.isa-status { font-size: 13px; color: var(--isa-head-sub); }
.isa-menu {
    position: absolute; right: 8px; top: calc(env(safe-area-inset-top) + 56px); z-index: 20;
    min-width: 220px; padding: 6px 0;
    background: #FFFFFF; color: var(--isa-ink);
    border-radius: 10px; box-shadow: 0 6px 24px rgba(11, 20, 26, 0.22);
    display: flex; flex-direction: column;
}
.isa-menu a, .isa-menu button {
    min-height: 44px; padding: 0 18px; border: 0; background: none; text-align: left;
    display: flex; align-items: center; font-size: 15px; color: var(--isa-ink); text-decoration: none;
}
.isa-menu a:hover, .isa-menu button:hover { background: #F0F2F5; }

/* Conversación */
.isa-chat {
    flex: 1; min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 12px 12px 8px;
    display: flex; flex-direction: column; gap: 2px;
    outline: none;
}
.isa-sys { display: flex; justify-content: center; margin: 4px 0; }
.isa-day {
    background: #FFFFFF; color: #54656F; font-size: 12px; font-weight: 600;
    padding: 5px 12px; border-radius: 8px; letter-spacing: 0.04em; box-shadow: var(--isa-shadow);
}
.isa-disclaimer {
    max-width: 320px; background: #FFF3C2; color: #54470F;
    font-size: 12.5px; line-height: 1.4; text-align: center;
    padding: 8px 12px; border-radius: 8px; margin-bottom: 6px;
}
.isa-row { display: flex; margin-top: 6px; }
.isa-row.isa-cont { margin-top: 2px; }
.isa-row.isa-me { justify-content: flex-end; }
.isa-bubble {
    position: relative;
    max-width: min(82%, 420px);
    padding: 7px 9px 6px 10px;
    border-radius: 8px;
    box-shadow: var(--isa-shadow);
    background: var(--isa-in);
    font-size: 15px; line-height: 1.38;
    overflow-wrap: anywhere;
}
.isa-isa .isa-bubble, .isa-team .isa-bubble { border-top-left-radius: 0; }
.isa-me .isa-bubble { background: var(--isa-out); border-top-right-radius: 0; }
.isa-cont .isa-bubble { border-radius: 8px; }
.isa-team .isa-bubble { background: #FFFFFF; }
.isa-team-name { font-size: 13px; font-weight: 600; color: #8A3B1E; margin-bottom: 2px; }
.isa-body p { margin: 0 0 6px; }
.isa-body p:last-child { margin-bottom: 0; }
.isa-body ul { margin: 2px 0 6px; padding-left: 20px; }
.isa-body li { margin: 2px 0; }
.isa-body a { color: #027EB5; }
.isa-meta {
    display: flex; justify-content: flex-end; align-items: center; gap: 3px;
    font-size: 11px; color: var(--isa-meta); margin-top: 2px;
}
.isa-state { display: inline-flex; color: var(--isa-meta); }
.isa-read .isa-state { color: var(--isa-read); }
.isa-failed .isa-state { color: #C0392B; font-weight: 700; }
.isa-sent-photo { display: block; width: 100%; max-width: 260px; border-radius: 6px; margin: -3px -4px 6px -5px; }

/* Indicador de escritura */
.isa-typing { display: flex; gap: 4px; padding: 12px 14px; }
.isa-typing span {
    width: 7px; height: 7px; border-radius: 50%; background: #8696A0;
    animation: isa-blink 1.2s infinite ease-in-out;
}
.isa-typing span:nth-child(2) { animation-delay: 0.2s; }
.isa-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes isa-blink { 0%, 80%, 100% { opacity: 0.3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) { .isa-typing span { animation: none; opacity: 0.7; } }

/* Burbujas con botones (bienvenida) */
.isa-quick { padding: 0; width: min(300px, 82%); overflow: hidden; }
.isa-quick .isa-body, .isa-quick .isa-meta { padding: 0 9px 0 10px; }
.isa-quick .isa-body { padding-top: 7px; }
.isa-quick .isa-meta { padding-bottom: 6px; }
.isa-quick-btn {
    width: 100%; min-height: 44px; border: 0; border-top: 1px solid var(--isa-line);
    background: #FFFFFF; color: var(--isa-accent);
    font-size: 15px; font-weight: 500; text-decoration: none;
    display: flex; align-items: center; justify-content: center; gap: 8px;
}
.isa-quick-btn:hover { background: #F5F7F8; }

/* Vista previa de enlaces (dentro del mensaje de la clienta) */
.o_isa_link {
    margin: 6px 0 2px; padding: 8px 10px;
    background: rgba(11, 20, 26, 0.05); border-radius: 6px; border: 0;
    display: flex; flex-direction: column; gap: 2px;
}
.o_isa_link_site { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--isa-meta); }
.isa-body .o_isa_link_title { font-weight: 600; color: var(--isa-ink); text-decoration: none; }
.o_isa_link_desc { font-size: 13px; color: var(--isa-ink-2); }
.o_isa_link_desc:empty { display: none; }
.o_isa_link_text { display: none; }

/* Tarjetas de producto de ISA */
.isa-has-cards .isa-bubble { max-width: 100%; }
.isa-body .o_isa_cards {
    display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x mandatory;
    margin: 8px -9px 2px -10px; padding: 2px 10px 6px;
    -webkit-overflow-scrolling: touch;
}
.isa-body .o_isa_card {
    flex: 0 0 156px; scroll-snap-align: start;
    background: #FFFFFF; border: 1px solid var(--isa-line); border-radius: 10px;
    overflow: hidden; display: flex; flex-direction: column;
}
.isa-body .o_isa_card_img { width: 100%; height: 110px; object-fit: contain; background: #F7F4F1; padding: 6px; }
.isa-body .o_isa_card_body { padding: 8px 10px 10px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.isa-body .o_isa_card_name { font-size: 14px; line-height: 1.3; font-weight: 600; color: var(--isa-ink); text-decoration: none; }
.isa-body .o_isa_card_meta { font-size: 13px; color: var(--isa-ink-2); }
.isa-body .o_isa_add {
    margin-top: auto; min-height: 40px; border-radius: 20px;
    background: var(--isa-head); color: #FFFFFF; font-size: 14px; font-weight: 600;
    display: flex; align-items: center; justify-content: center; text-align: center;
    text-decoration: none; padding: 0 10px;
}
.isa-body .o_isa_add.o_isa_added { background: #E7F4F1; color: var(--isa-accent); }
.isa-body .o_isa_cart_link { font-size: 13px; text-align: center; color: var(--isa-accent); font-weight: 600; }

/* Avisos */
.isa-notice {
    position: absolute; left: 50%; bottom: 84px; transform: translateX(-50%); z-index: 30;
    max-width: calc(100% - 32px); padding: 10px 14px; border-radius: 10px;
    background: #2A3942; color: #FFFFFF; font-size: 14px; line-height: 1.35; text-align: center;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

/* Barra de escritura */
.isa-composer {
    flex-shrink: 0; display: flex; align-items: flex-end; gap: 6px;
    padding: 6px 8px calc(10px + env(safe-area-inset-bottom));
    background: var(--isa-wall); margin: 0;
}
.isa-input-wrap {
    flex: 1; min-height: 48px; display: flex; align-items: flex-end; gap: 0;
    background: #FFFFFF; border-radius: 24px; padding: 2px 4px 2px 16px; box-shadow: var(--isa-shadow);
}
.isa-input-wrap textarea {
    flex: 1; min-width: 0; border: 0; outline: none; resize: none; background: transparent;
    font-size: 16px; line-height: 22px; padding: 11px 0; max-height: 120px; color: var(--isa-ink);
}
.isa-input-wrap textarea::placeholder { color: #667781; }
.isa-send {
    width: 48px; height: 48px; flex-shrink: 0; border: 0; border-radius: 50%;
    background: var(--isa-head); color: #FFFFFF;
    display: flex; align-items: center; justify-content: center;
}

/* Hoja de adjuntar */
.isa-sheet {
    flex-shrink: 0; background: #FFFFFF; border-radius: 20px 20px 0 0;
    box-shadow: 0 -2px 12px rgba(11, 20, 26, 0.12);
    padding: 10px 20px calc(22px + env(safe-area-inset-bottom));
    display: flex; flex-direction: column; gap: 18px;
}
.isa-grip { align-self: center; width: 36px; height: 4px; border-radius: 2px; background: #D1D7DB; }
.isa-sheet-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.isa-sheet-btn {
    border: 0; background: transparent; padding: 0;
    display: flex; flex-direction: column; align-items: center; gap: 8px;
    font-size: 13px; color: var(--isa-ink-2);
}
.isa-sheet-ico { width: 56px; height: 56px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.isa-c-teal { background: #E7F4F1; color: #0B4A43; }
.isa-c-sand { background: #F4E6D8; color: #5A3E36; }
.isa-c-blue { background: #E6EEF8; color: #1F4F86; }
.isa-c-grey { background: #F0F2F5; color: #3B4A54; }
.isa-sheet-note { margin: 0; font-size: 12.5px; line-height: 1.4; color: #54656F; text-align: center; }

/* Foto: vista previa y consentimiento */
.isa-photo {
    position: absolute; inset: 0; z-index: 40;
    background: #0B141A; color: #E9EDEF;
    display: flex; flex-direction: column;
    padding-top: env(safe-area-inset-top);
}
.isa-photo-top { height: 64px; flex-shrink: 0; display: flex; align-items: center; justify-content: space-between; padding: 0 8px; font-size: 15px; color: #AEBAC1; }
.isa-photo-gap { width: 44px; }
.isa-photo-view { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 0 16px 12px; }
.isa-photo-view img { max-width: 100%; max-height: 100%; border-radius: 6px; object-fit: contain; }
.isa-consent {
    margin: 0 12px 10px; background: #FFFFFF; color: var(--isa-ink);
    border-radius: 16px 16px 4px 4px; padding: 16px 18px 12px;
    display: flex; flex-direction: column; gap: 10px;
}
.isa-consent-head { display: flex; align-items: center; gap: 10px; }
.isa-consent-icon { width: 36px; height: 36px; flex-shrink: 0; border-radius: 50%; background: #E7F4F1; color: #0B4A43; display: flex; align-items: center; justify-content: center; }
.isa-consent h2 { margin: 0; font-size: 17px; font-weight: 600; }
.isa-consent p { margin: 0; font-size: 14.5px; line-height: 1.45; color: var(--isa-ink-2); }
.isa-consent a { font-size: 13.5px; color: var(--isa-accent); }
.isa-photo-bar { flex-shrink: 0; display: flex; align-items: center; gap: 8px; padding: 6px 12px 12px; }
.isa-needs-consent .isa-photo-bar { background: #FFFFFF; margin: 0 12px; padding: 0 12px 10px; border-radius: 0; }
.isa-needs-consent #isa-photo-send { display: none; }
.isa-photo-bar input {
    flex: 1; min-width: 0; min-height: 48px; border-radius: 24px; border: 0; outline: none;
    padding: 0 16px; font-size: 16px; background: #2A3942; color: #E9EDEF;
}
.isa-needs-consent .isa-photo-bar input { background: #F0F2F5; color: var(--isa-ink); }
.isa-consent-btns {
    flex-shrink: 0; display: flex; gap: 10px;
    margin: 0 12px calc(12px + env(safe-area-inset-bottom));
    background: #FFFFFF; border-radius: 4px 4px 16px 16px; padding: 4px 18px 16px;
}
.isa-btn, .isa-btn-ghost {
    min-height: 48px; border-radius: 24px; font-size: 15px;
    display: flex; align-items: center; justify-content: center; gap: 8px;
}
.isa-btn-ghost { flex: 1; border: 1px solid #D1D7DB; background: #FFFFFF; color: var(--isa-ink-2); font-weight: 500; }
.isa-btn { flex: 1.4; border: 0; background: var(--isa-head); color: #FFFFFF; font-weight: 600; }

/* Enviarme la conversación */
.isa-share { gap: 14px; }
.isa-share-title { margin: 0; font-size: 17px; font-weight: 600; text-align: center; color: var(--isa-ink); }
.isa-share-opts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.isa-share-opt {
    border: 1px solid var(--isa-line); background: #FFFFFF; border-radius: 14px; padding: 14px 8px;
    display: flex; flex-direction: column; align-items: center; gap: 8px; font-size: 15px; font-weight: 500;
    color: var(--isa-ink);
}
.isa-share-form { display: flex; flex-direction: column; gap: 8px; margin: 0; }
.isa-share-form label { font-size: 15px; font-weight: 500; color: var(--isa-ink); }
.isa-share-row { display: flex; gap: 8px; align-items: center; }
.isa-share-row input {
    flex: 1; min-width: 0; min-height: 48px; border-radius: 24px; border: 1px solid #D1D7DB;
    padding: 0 16px; font-size: 16px; outline: none; color: var(--isa-ink);
}
.isa-share-row input:focus { border-color: var(--isa-head); }
.isa-share .isa-btn-ghost { flex: none; }
