/* ── Chatbot IA — Frontend Widget ── */
#cia-fab {
    position: fixed;
    bottom: 28px;
    right: 28px;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: var(--cia-color, #111);
    color: #fff;
    border: none;
    font-size: 26px;
    cursor: pointer;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(0,0,0,.22);
    transition: transform .15s, box-shadow .15s;
}
#cia-fab:hover { transform: scale(1.07); box-shadow: 0 6px 28px rgba(0,0,0,.28); }

#cia-win {
    position: fixed;
    bottom: 98px;
    right: 28px;
    width: var(--cia-width, 360px);
    max-height: var(--cia-max-height, 520px);
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 8px 48px rgba(0,0,0,.16);
    z-index: 99998;
    display: none;
    flex-direction: column;
    overflow: hidden;
    font-family: system-ui, -apple-system, sans-serif;
    opacity: 0;
    transform: translateY(14px);
    transition: opacity .22s ease, transform .22s ease;
}
#cia-win.cia-open {
    display: flex;
    opacity: 1;
    transform: translateY(0);
}

/* Header */
#cia-header {
    background: var(--cia-color, #111);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}
.cia-w-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: rgba(255,255,255,.18);
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; flex-shrink: 0;
}
.cia-w-name { font-size: 14px; font-weight: 600; }
.cia-w-status { font-size: 11px; opacity: .7; display: flex; align-items: center; gap: 4px; }
.cia-w-dot { width: 7px; height: 7px; border-radius: 50%; background: #4ade80; display: inline-block; }
#cia-close {
    margin-left: auto; background: none; border: none; color: #fff;
    font-size: 22px; cursor: pointer; opacity: .7; line-height: 1; padding: 0 2px;
}
#cia-close:hover { opacity: 1; }

/* Messages */
#cia-msgs {
    flex: 1; overflow-y: auto; padding: 14px 12px;
    display: flex; flex-direction: column; gap: 10px;
    scroll-behavior: smooth;
}
#cia-msgs::-webkit-scrollbar { width: 4px; }
#cia-msgs::-webkit-scrollbar-thumb { background: #ddd; border-radius: 4px; }

.cia-w-msg {
    max-width: 82%; font-size: 13.5px; line-height: 1.55;
    padding: 9px 13px; border-radius: 14px; word-break: break-word;
    animation: ciaFadeIn .18s ease;
}
@keyframes ciaFadeIn { from { opacity:0; transform:translateY(4px); } to { opacity:1; transform:none; } }
.cia-w-bot  { background: #f0f0f0; color: #111; align-self: flex-start; border-bottom-left-radius: 4px; }
.cia-w-user { background: var(--cia-color, #111); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }

/* Typing indicator */
.cia-typing-dots { display: flex; gap: 4px; padding: 4px 0; }
.cia-typing-dots span {
    width: 7px; height: 7px; border-radius: 50%; background: #aaa;
    animation: ciaBounce 1.1s infinite;
}
.cia-typing-dots span:nth-child(2) { animation-delay: .18s; }
.cia-typing-dots span:nth-child(3) { animation-delay: .36s; }
@keyframes ciaBounce {
    0%,80%,100% { transform: scale(.7); opacity: .5; }
    40%          { transform: scale(1);  opacity: 1;  }
}

/* Input */
#cia-input-row {
    display: flex; gap: 8px; padding: 10px 12px;
    border-top: 1px solid #eee; flex-shrink: 0;
}
#cia-input {
    flex: 1; font-size: 13.5px; border: 1.5px solid #e0e0e0;
    border-radius: 22px; padding: 8px 14px; outline: none; font-family: inherit;
    transition: border-color .15s;
}
#cia-input:focus { border-color: #999; }
#cia-send {
    background: var(--cia-color, #111); color: #fff; border: none;
    border-radius: 50%; width: 38px; height: 38px; flex-shrink: 0;
    cursor: pointer; font-size: 16px; display: flex; align-items: center; justify-content: center;
    transition: opacity .15s;
}
#cia-send:disabled { opacity: .45; cursor: default; }

#cia-photo-btn {
    background: none; border: none; font-size: 18px; cursor: pointer;
    flex-shrink: 0; opacity: .65; transition: opacity .15s;
    display: flex; align-items: center; justify-content: center; width: 28px;
}
#cia-photo-btn:hover { opacity: 1; }

/* Responsive */
@media (max-width: 480px) {
    #cia-win  { width: calc(100vw - 20px); right: 10px; bottom: 84px; }
    #cia-fab  { right: 14px; bottom: 14px; }
}

/* ── Fase 2: Consentimiento ── */
.cia-consent-msg p { margin: 0 0 10px; line-height: 1.5; font-size: 13px; }
.cia-consent-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.cia-btn-accept, .cia-btn-decline {
    padding: 7px 14px; border-radius: 20px; font-size: 12px;
    cursor: pointer; border: none; font-weight: 500;
}
.cia-btn-accept  { background: var(--cia-color, #111); color: #fff; }
.cia-btn-decline { background: #e5e7eb; color: #374151; }
.cia-btn-accept:hover  { opacity: .88; }
.cia-btn-decline:hover { background: #d1d5db; }

/* ── Barra de privacidad ── */
#cia-privacy-row {
    padding: 4px 12px 6px;
    text-align: right;
    border-top: none;
    background: transparent;
}
#cia-privacy-btn {
    background: none;
    border: none;
    font-size: 11px;
    color: #aaa;
    cursor: pointer;
    padding: 2px 4px;
}
#cia-privacy-btn:hover { color: #666; }
