/* IAChat - widget propio. Ajusta los colores de marca en las variables. */
.iachat-root {
    --iachat-primary: #1f2a44;
    --iachat-accent: #c8a15a;
    --iachat-bg: #ffffff;
    --iachat-bot: #f1f3f7;
    --iachat-text: #1f2330;
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 2147483000;
    font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.iachat-bubble {
    width: 60px; height: 60px;
    border-radius: 50%;
    border: none;
    background: var(--iachat-primary);
    color: #fff;
    font-size: 26px;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(0,0,0,.25);
    display: flex; align-items: center; justify-content: center;
    transition: transform .15s ease;
}
.iachat-bubble:hover { transform: scale(1.06); }
.iachat-bubble.iachat-open { transform: scale(.9); }

.iachat-panel {
    position: absolute;
    right: 0; bottom: 74px;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 600px;
    max-height: calc(100vh - 120px);
    background: var(--iachat-bg);
    border-radius: 14px;
    box-shadow: 0 12px 40px rgba(0,0,0,.28);
    display: flex; flex-direction: column;
    overflow: hidden;
}
.iachat-hidden { display: none; }

.iachat-header {
    background: var(--iachat-primary);
    color: #fff;
    padding: 14px 16px;
    display: flex; align-items: center; justify-content: space-between;
}
.iachat-title { font-weight: 600; font-size: 15px; }
.iachat-close {
    background: none; border: none; color: #fff;
    font-size: 24px; line-height: 1; cursor: pointer; opacity: .85;
}
.iachat-close:hover { opacity: 1; }

/* barra de filtros activos (publico / talla) */
.iachat-filters {
    display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
    padding: 8px 12px;
    background: #f1f3f7;
    border-bottom: 1px solid #e0e6ed;
    font-size: 12px;
}
.iachat-filters-label { color: #6b7280; }
.iachat-filter-chip {
    display: inline-flex; align-items: center;
    background: var(--iachat-primary); color: #fff;
    border-radius: 12px; padding: 3px 4px 3px 10px; font-size: 12px;
}
.iachat-filter-x {
    border: none; background: rgba(255,255,255,.25); color: #fff;
    width: 18px; height: 18px; border-radius: 50%; margin-left: 6px;
    cursor: pointer; line-height: 1; font-size: 13px; padding: 0;
}
.iachat-filter-x:hover { background: rgba(255,255,255,.45); }
.iachat-filter-change {
    border: none; background: none; color: var(--iachat-primary);
    text-decoration: underline; cursor: pointer; font-size: 12px; padding: 2px 4px;
}

.iachat-body {
    flex: 1; overflow-y: auto;
    padding: 14px;
    display: flex; flex-direction: column; gap: 10px;
    background: #fafbfc;
}

.iachat-msg { display: flex; }
.iachat-user { justify-content: flex-end; }
.iachat-bot { justify-content: flex-start; }
.iachat-bubble-text {
    max-width: 80%;
    padding: 9px 13px;
    border-radius: 14px;
    font-size: 14px; line-height: 1.45;
    word-wrap: break-word;
}
.iachat-user .iachat-bubble-text {
    background: var(--iachat-primary); color: #fff;
    border-bottom-right-radius: 4px;
}
.iachat-bot .iachat-bubble-text {
    background: var(--iachat-bot); color: var(--iachat-text);
    border-bottom-left-radius: 4px;
}

/* typing */
.iachat-typing .iachat-bubble-text { display: flex; gap: 4px; }
.iachat-typing span {
    width: 7px; height: 7px; border-radius: 50%;
    background: #9aa3b2; display: inline-block;
    animation: iachat-blink 1.2s infinite both;
}
.iachat-typing span:nth-child(2) { animation-delay: .2s; }
.iachat-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes iachat-blink { 0%,80%,100% { opacity: .3; } 40% { opacity: 1; } }

/* tarjetas de producto */
.iachat-products { display: flex; flex-direction: column; gap: 8px; }
.iachat-card {
    display: flex; flex-direction: column;
    background: #fff; border: 1px solid #e6e9ef; border-radius: 10px;
    padding: 8px;
    transition: box-shadow .15s ease;
}
.iachat-card:hover { box-shadow: 0 4px 14px rgba(0,0,0,.12); }
.iachat-card-link { display: flex; gap: 10px; text-decoration: none; color: var(--iachat-text); }
.iachat-card-actions { display: flex; gap: 6px; margin-top: 8px; align-items: center; }
.iachat-size-select { flex: 1; padding: 6px 8px; border: 1px solid #d4d9e2; border-radius: 6px; font-size: 13px; background: #fff; }
.iachat-size-select.iachat-need { border-color: #d9534f; }
.iachat-add-btn { border: none; background: var(--iachat-primary); color: #fff; padding: 7px 14px; border-radius: 6px; font-size: 13px; cursor: pointer; flex: 0 0 auto; }
.iachat-add-btn:hover { background: var(--iachat-accent); }
.iachat-add-btn:disabled { opacity: .6; cursor: default; }
.iachat-card-img {
    width: 64px; height: 64px; object-fit: cover; border-radius: 8px; flex: 0 0 auto;
    background: #eef0f4;
}
.iachat-card-noimg { background: #eef0f4; }
.iachat-card-info { display: flex; flex-direction: column; justify-content: center; gap: 3px; min-width: 0; }
.iachat-card-name { font-size: 13px; font-weight: 600; line-height: 1.3; }
.iachat-card-meta { font-size: 12px; }
.iachat-card-price { color: var(--iachat-primary); font-weight: 700; }
.iachat-card-stock { color: #5b8a3c; margin-left: 6px; }

/* enlace "ver mas en la categoria" */
.iachat-catlink { margin-top: 2px; }
.iachat-cat-btn {
    display: inline-block;
    border: 1px solid var(--iachat-accent);
    color: var(--iachat-primary);
    background: #fff;
    border-radius: 16px;
    padding: 7px 14px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
}
.iachat-cat-btn:hover { background: var(--iachat-accent); color: #fff; }

/* selector de talla al abrir */
.iachat-tallasel { margin-top: 2px; }
.iachat-tallasel-label { font-size: 13px; color: var(--iachat-text); margin-bottom: 6px; }
.iachat-tallasel-row { display: flex; flex-wrap: wrap; gap: 6px; }
.iachat-talla-chip {
    min-width: 38px;
    border: 1px solid var(--iachat-primary);
    background: #fff;
    color: var(--iachat-primary);
    border-radius: 8px;
    padding: 7px 10px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background .12s ease, color .12s ease;
}
.iachat-talla-chip:hover { background: var(--iachat-primary); color: #fff; }
.iachat-talla-none { border-color: #9aa3b2; color: #6b7280; font-weight: 400; }

/* botones de respuesta rapida (chips) */
.iachat-quickreplies {
    display: flex; flex-wrap: wrap; gap: 6px;
    margin-top: 2px;
}
.iachat-chip {
    border: 1px solid var(--iachat-primary);
    background: #fff;
    color: var(--iachat-primary);
    border-radius: 16px;
    padding: 6px 12px;
    font-size: 13px;
    cursor: pointer;
    transition: background .12s ease, color .12s ease;
}
.iachat-chip:hover { background: var(--iachat-primary); color: #fff; }

.iachat-footer {
    display: flex; gap: 8px; padding: 10px;
    border-top: 1px solid #e6e9ef; background: #fff;
}
.iachat-input {
    flex: 1; border: 1px solid #d4d9e2; border-radius: 20px;
    padding: 9px 14px; font-size: 14px; outline: none;
}
.iachat-input:focus { border-color: var(--iachat-primary); }
.iachat-send {
    border: none; background: var(--iachat-primary); color: #fff;
    width: 40px; height: 40px; border-radius: 50%; cursor: pointer; font-size: 16px;
    flex: 0 0 auto;
}
.iachat-send:hover { background: var(--iachat-accent); }

@media (max-width: 480px) {
    .iachat-panel { width: calc(100vw - 24px); height: calc(100vh - 100px); }
}
