/* ============================================================
   Asistente IA tee.cl — widget flotante
   ============================================================ */

#teeAsstBubble {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: #10b981;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.28);
    z-index: 99990;
    opacity: 0;
    transform: scale(0.5);
    transition: all 0.35s ease;
}
#teeAsstBubble.teeAsstShow { opacity: 1; transform: scale(1); }
#teeAsstBubble:hover { transform: scale(1.07); box-shadow: 0 6px 18px rgba(0,0,0,0.32); }
#teeAsstBubble svg { width: 28px; height: 28px; fill: #fff; }
#teeAsstBubble .teeAsstBadge {
    position: absolute;
    top: -3px;
    right: -3px;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    background: #ef4444;
    color: #fff;
    font: 700 11px/20px Arial, sans-serif;
    text-align: center;
    padding: 0 4px;
    display: none;
}
#teeAsstBubble .teeAsstBadge.on { display: block; }

/* Globo proactivo (llamado de acción) */
#teeAsstNudge {
    position: fixed;
    bottom: 88px;
    right: 20px;
    max-width: 240px;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
    padding: 12px 30px 12px 14px;
    z-index: 99989;
    opacity: 0;
    transform: translateY(10px) scale(0.9);
    transform-origin: bottom right;
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
}
#teeAsstNudge.teeAsstShow {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}
#teeAsstNudge::after {
    content: '';
    position: absolute;
    bottom: -7px;
    right: 22px;
    width: 14px;
    height: 14px;
    background: #fff;
    transform: rotate(45deg);
    box-shadow: 3px 3px 6px rgba(0, 0, 0, 0.06);
}
#teeAsstNudge .teeAsstNudgeText {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    font-size: 13.5px;
    line-height: 1.4;
    color: #222;
    cursor: pointer;
}
#teeAsstNudge .teeAsstNudgeClose {
    position: absolute;
    top: 6px;
    right: 8px;
    background: none;
    border: none;
    font-size: 17px;
    line-height: 1;
    color: #9aa7a1;
    cursor: pointer;
    padding: 2px;
}
#teeAsstNudge .teeAsstNudgeClose:hover { color: #444; }

#teeAsstPanel {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 372px;
    max-width: calc(100vw - 24px);
    height: 560px;
    max-height: calc(100vh - 110px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 99991;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}
#teeAsstPanel.open { display: flex; }

.teeAsstHeader {
    background: #10b981;
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.teeAsstHeader .teeAsstAvatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    display: flex; align-items: center; justify-content: center;
    flex: none;
}
.teeAsstHeader .teeAsstAvatar svg { width: 20px; height: 20px; fill: #fff; }
.teeAsstHeader .teeAsstTitle { font-size: 15px; font-weight: 700; line-height: 1.2; }
.teeAsstHeader .teeAsstSub { font-size: 11.5px; opacity: 0.85; }
.teeAsstHeader .teeAsstClose {
    margin-left: auto;
    background: none; border: none; color: #fff;
    font-size: 22px; line-height: 1; cursor: pointer; opacity: 0.85; padding: 4px;
}
.teeAsstHeader .teeAsstClose:hover { opacity: 1; }

.teeAsstBody {
    flex: 1;
    overflow-y: auto;
    padding: 14px 12px;
    background: #f6f8f7;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.teeAsstMsg {
    max-width: 85%;
    padding: 9px 12px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.45;
    white-space: pre-wrap;
    word-wrap: break-word;
}
.teeAsstMsg a { color: #0d9668; font-weight: 600; }
.teeAsstMsg.user {
    align-self: flex-end;
    background: #10b981;
    color: #fff;
    border-bottom-right-radius: 4px;
}
.teeAsstMsg.user a { color: #eafff6; }
.teeAsstMsg.assistant, .teeAsstMsg.admin {
    align-self: flex-start;
    background: #fff;
    color: #222;
    border: 1px solid #e6eae8;
    border-bottom-left-radius: 4px;
}
.teeAsstMsg.admin { border-color: #10b981; }
.teeAsstMsg .teeAsstMsgTag {
    display: block;
    font-size: 10.5px;
    font-weight: 700;
    color: #0d9668;
    margin-bottom: 3px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.teeAsstImg {
    display: block;
    max-width: 100%;
    max-height: 220px;
    border-radius: 10px;
    cursor: pointer;
}

.teeAsstInputRow button.teeAsstAttachBtn {
    flex: none;
    width: 42px;
    height: 42px;
    border-radius: 10px;
    border: 1px solid #d7ddda;
    background: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    align-self: flex-end;
    padding: 0;
}
.teeAsstInputRow button.teeAsstAttachBtn:hover { background: #f0fdf8; }
.teeAsstInputRow button.teeAsstAttachBtn svg { width: 20px; height: 20px; fill: #6b7d75; }

.teeAsstPreview:not(:empty) { margin-bottom: 8px; }
.teeAsstChip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #eef4f1;
    border-radius: 10px;
    padding: 6px 8px;
    font-size: 12px;
    color: #6b7d75;
}
.teeAsstChip img { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; }
.teeAsstChipX {
    background: none;
    border: none;
    font-size: 18px;
    line-height: 1;
    color: #6b7d75;
    cursor: pointer;
    padding: 0 2px;
}

.teeAsstNote {
    align-self: center;
    max-width: 90%;
    text-align: center;
    font-size: 12px;
    color: #6b7d75;
    background: #eef4f1;
    border-radius: 10px;
    padding: 7px 12px;
    line-height: 1.4;
}

.teeAsstMoreBtn {
    align-self: center;
    background: #fff;
    border: 1px solid #d7ddda;
    color: #0d9668;
    border-radius: 999px;
    padding: 5px 14px;
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    margin-bottom: 4px;
    flex: none;
}
.teeAsstMoreBtn:hover { background: #f0fdf8; }
.teeAsstMoreBtn:disabled { opacity: 0.6; cursor: default; }

.teeAsstTyping {
    align-self: flex-start;
    background: #fff;
    border: 1px solid #e6eae8;
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    padding: 12px 14px;
    display: flex;
    gap: 4px;
}
.teeAsstTyping span {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: #9db5ab;
    animation: teeAsstBlink 1.2s infinite both;
}
.teeAsstTyping span:nth-child(2) { animation-delay: 0.2s; }
.teeAsstTyping span:nth-child(3) { animation-delay: 0.4s; }
@keyframes teeAsstBlink {
    0%, 80%, 100% { opacity: 0.25; }
    40% { opacity: 1; }
}

.teeAsstFooter {
    border-top: 1px solid #e8ecea;
    background: #fff;
    padding: 10px;
}
.teeAsstInputRow { display: flex; gap: 8px; }
.teeAsstInputRow textarea {
    flex: 1;
    resize: none;
    border: 1px solid #d7ddda;
    border-radius: 10px;
    padding: 9px 11px;
    font-size: 13.5px;
    font-family: inherit;
    line-height: 1.4;
    max-height: 90px;
    outline: none;
}
.teeAsstInputRow textarea:focus { border-color: #10b981; }
.teeAsstInputRow button {
    flex: none;
    width: 42px; height: 42px;
    border-radius: 10px;
    border: none;
    background: #10b981;
    color: #fff;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    align-self: flex-end;
}
.teeAsstInputRow button:disabled { opacity: 0.5; cursor: default; }
.teeAsstInputRow button svg { width: 18px; height: 18px; fill: #fff; }
.teeAsstAlt {
    text-align: center;
    font-size: 11px;
    color: #9aa7a1;
    margin-top: 7px;
}
.teeAsstAlt a { color: #9aa7a1; text-decoration: underline; }

/* --- Formulario de contacto --- */
.teeAsstForm { padding: 6px 4px; display: flex; flex-direction: column; gap: 9px; }
.teeAsstForm .teeAsstFormIntro { font-size: 13px; color: #445; line-height: 1.45; }
.teeAsstForm input {
    border: 1px solid #d7ddda;
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 13.5px;
    font-family: inherit;
    outline: none;
}
.teeAsstForm input:focus { border-color: #10b981; }
.teeAsstForm button {
    background: #10b981;
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 11px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
}
.teeAsstForm button:hover { background: #0d9668; }
.teeAsstForm .teeAsstFormErr { color: #ef4444; font-size: 12px; display: none; }

@media (max-width: 480px) {
    #teeAsstPanel {
        right: 12px;
        bottom: 84px;
        width: calc(100vw - 24px);
        height: calc(100vh - 100px);
    }
}
