/* ===== ZonaCNC Chat IA — widget flotante ===== */
:root {
    --zcnc-chat-primary: #c81a1a;
    --zcnc-chat-primary-dark: #a31414;
    --zcnc-chat-bg: #ffffff;
    --zcnc-chat-text: #2b2b2b;
    --zcnc-chat-text-muted: #6b6b6b;
    --zcnc-chat-border: #e6e6e6;
    --zcnc-chat-bubble-user: #f3f0ee;
    --zcnc-chat-bubble-bot: #fff5f5;
    --zcnc-chat-shadow: 0 8px 32px rgba(0, 0, 0, .18);
}

#zcnc-chat-root { display: contents; }
#zcnc-chat-root[hidden] { display: none; }

/* Botón flotante */
.zcnc-chat-fab {
    position: fixed; right: 20px; bottom: 20px; z-index: 9998;
    width: 60px; height: 60px; border-radius: 50%;
    background: var(--zcnc-chat-primary); color: #fff;
    border: none; cursor: pointer;
    box-shadow: var(--zcnc-chat-shadow);
    display: flex; align-items: center; justify-content: center;
    transition: transform .15s, background .15s;
}
.zcnc-chat-fab:hover { background: var(--zcnc-chat-primary-dark); transform: scale(1.06); }
.zcnc-chat-fab svg { width: 28px; height: 28px; }

/* Panel */
.zcnc-chat-panel {
    position: fixed; right: 20px; bottom: 92px; z-index: 9999;
    width: 380px; max-width: calc(100vw - 32px);
    height: 540px; max-height: calc(100vh - 120px);
    background: var(--zcnc-chat-bg); color: var(--zcnc-chat-text);
    border-radius: 14px; box-shadow: var(--zcnc-chat-shadow);
    display: flex; flex-direction: column; overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px; line-height: 1.45;
}
@media (max-width: 480px) {
    .zcnc-chat-panel {
        right: 0; bottom: 0; width: 100vw; height: 100vh;
        border-radius: 0; max-height: 100vh;
    }
}

.zcnc-chat-header {
    background: var(--zcnc-chat-primary); color: #fff;
    padding: 14px 16px; display: flex; align-items: center; justify-content: space-between;
}
.zcnc-chat-header h3 {
    margin: 0; font-size: 15px; font-weight: 600;
    display: flex; align-items: center; gap: 8px;
}
.zcnc-chat-header h3 .zcnc-status-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: #6cd97e; box-shadow: 0 0 0 2px rgba(108, 217, 126, .25);
}
.zcnc-chat-header-actions { display: flex; gap: 6px; }
.zcnc-chat-iconbtn {
    background: transparent; border: none; color: rgba(255,255,255,.85);
    cursor: pointer; padding: 4px 6px; border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
}
.zcnc-chat-iconbtn:hover { background: rgba(255,255,255,.15); color: #fff; }
.zcnc-chat-iconbtn svg { width: 18px; height: 18px; }

/* Mensajes */
.zcnc-chat-messages {
    flex: 1; overflow-y: auto; padding: 14px;
    display: flex; flex-direction: column; gap: 10px;
    background: linear-gradient(180deg, #fafafa 0%, #fff 60%);
}
.zcnc-chat-msg {
    max-width: 85%; padding: 10px 12px; border-radius: 12px;
    word-wrap: break-word; white-space: pre-wrap;
}
.zcnc-chat-msg.bot {
    background: var(--zcnc-chat-bubble-bot); align-self: flex-start;
    border-bottom-left-radius: 4px;
}
.zcnc-chat-msg.user {
    background: var(--zcnc-chat-bubble-user); align-self: flex-end;
    border-bottom-right-radius: 4px;
}
.zcnc-chat-msg.error {
    background: #fee; color: #a00; align-self: flex-start;
    border: 1px solid #f5c6c6;
}
.zcnc-chat-msg a {
    color: var(--zcnc-chat-primary); text-decoration: underline; word-break: break-all;
}
.zcnc-chat-msg ul { margin: 6px 0 0; padding-left: 20px; }
.zcnc-chat-msg li { margin-bottom: 3px; }

/* Indicador escribiendo */
.zcnc-chat-typing { display: flex; gap: 4px; padding: 8px 12px; }
.zcnc-chat-typing span {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--zcnc-chat-primary); opacity: .35;
    animation: zcnc-bounce 1.2s infinite ease-in-out;
}
.zcnc-chat-typing span:nth-child(2) { animation-delay: .15s; }
.zcnc-chat-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes zcnc-bounce {
    0%, 80%, 100% { opacity: .35; transform: translateY(0); }
    40% { opacity: 1; transform: translateY(-4px); }
}

/* Input */
.zcnc-chat-input-row {
    padding: 10px; display: flex; gap: 8px;
    border-top: 1px solid var(--zcnc-chat-border);
    background: #fff;
}
.zcnc-chat-input {
    flex: 1; resize: none; border: 1px solid var(--zcnc-chat-border);
    border-radius: 10px; padding: 9px 12px; font-size: 14px;
    font-family: inherit; max-height: 120px; outline: none;
    transition: border-color .15s;
}
.zcnc-chat-input:focus { border-color: var(--zcnc-chat-primary); }
.zcnc-chat-send {
    background: var(--zcnc-chat-primary); color: #fff; border: none;
    padding: 0 14px; border-radius: 10px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background .15s;
}
.zcnc-chat-send:hover { background: var(--zcnc-chat-primary-dark); }
.zcnc-chat-send:disabled { background: #c0c0c0; cursor: not-allowed; }
.zcnc-chat-send svg { width: 18px; height: 18px; }

.zcnc-chat-footer {
    padding: 6px 12px 8px; font-size: 11px; color: var(--zcnc-chat-text-muted);
    text-align: center; background: #fff; border-top: 1px solid var(--zcnc-chat-border);
}
