/* ── Chat Widget — Tecno Office ─────────────────────────────── */
#to-chat-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9990;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
}

/* Botón flotante */
#to-chat-fab {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #1b47a0;
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(0,0,0,.25);
    transition: background .2s, transform .2s;
    position: relative;
    margin-left: auto;
}
#to-chat-fab:hover { background: #0c2c66; transform: scale(1.07); }
#to-chat-fab svg  { width: 26px; height: 26px; fill: #fff; }

/* Badge de bienvenida */
#to-chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #e53e3e;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    display: none;
}

/* Ventana del chat */
#to-chat-window {
    position: absolute;
    bottom: 68px;
    right: 0;
    width: 340px;
    max-height: 520px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
    transition: opacity .2s, transform .2s;
}
#to-chat-window.hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(.92) translateY(12px);
}

/* Header */
#to-chat-header {
    background: linear-gradient(135deg, #1b47a0 0%, #0c2c66 100%);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}
#to-chat-header .to-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255,255,255,.2);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
#to-chat-header .to-avatar svg { width: 22px; height: 22px; fill: #fff; }
#to-chat-header .to-info { flex: 1; line-height: 1.3; }
#to-chat-header .to-title { font-weight: 700; font-size: 14px; }
#to-chat-header .to-status { font-size: 12px; opacity: .85; }
#to-chat-close {
    background: transparent;
    border: none;
    color: #fff;
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    padding: 0;
    opacity: .8;
}
#to-chat-close:hover { opacity: 1; }

/* Cuerpo */
#to-chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f7f9fc;
}

/* Formulario de inicio */
#to-chat-form-wrap { display: flex; flex-direction: column; gap: 10px; }
#to-chat-form-wrap .to-label {
    font-size: 13px;
    color: #555;
    margin-bottom: 14px;
    line-height: 1.5;
}
#to-chat-form-wrap input,
#to-chat-form-wrap textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #d0d7e3;
    border-radius: 8px;
    font-size: 13px;
    outline: none;
    transition: border-color .2s;
    box-sizing: border-box;
    font-family: inherit;
}
#to-chat-form-wrap input:focus,
#to-chat-form-wrap textarea:focus { border-color: #1b47a0; }
#to-chat-form-wrap textarea { resize: none; height: 70px; }
#to-chat-submit {
    background: #1b47a0;
    color: #fff;
    border: none;
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: background .2s;
}
#to-chat-submit:hover { background: #0c2c66; }
#to-chat-submit:disabled { opacity: .6; cursor: default; }

/* Burbujas de mensajes */
.to-msg {
    display: flex;
    flex-direction: column;
    max-width: 80%;
}
.to-msg.agent { align-self: flex-start; }
.to-msg.client { align-self: flex-end; }
.to-msg .to-bubble {
    padding: 9px 13px;
    border-radius: 14px;
    font-size: 13px;
    line-height: 1.5;
    word-break: break-word;
}
.to-msg.agent .to-bubble {
    background: #fff;
    color: #1a1a2e;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 4px;
}
.to-msg.client .to-bubble {
    background: #1b47a0;
    color: #fff;
    border-bottom-right-radius: 4px;
}
.to-msg .to-time {
    font-size: 10px;
    color: #999;
    margin-top: 3px;
    padding: 0 4px;
}
.to-msg.client .to-time { align-self: flex-end; }

/* Mensaje de estado (sistema) */
.to-msg-status {
    text-align: center;
    font-size: 12px;
    color: #888;
    padding: 4px 0;
}

/* Footer input */
#to-chat-footer {
    display: flex;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid #e9eef5;
    background: #fff;
    flex-shrink: 0;
    align-items: flex-end;
}
#to-chat-input {
    flex: 1;
    border: 1px solid #d0d7e3;
    border-radius: 20px;
    padding: 8px 14px;
    font-size: 13px;
    outline: none;
    resize: none;
    font-family: inherit;
    line-height: 1.4;
    max-height: 80px;
    overflow-y: auto;
    transition: border-color .2s;
}
#to-chat-input:focus { border-color: #1b47a0; }
#to-chat-send {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #1b47a0;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background .2s;
}
#to-chat-send:hover { background: #0c2c66; }
#to-chat-send:disabled { opacity: .5; cursor: default; }
#to-chat-send svg { width: 16px; height: 16px; fill: #fff; }

/* Nueva conversación */
#to-new-chat-btn {
    display: block;
    text-align: center;
    background: transparent;
    border: 1px solid #1b47a0;
    color: #1b47a0;
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 12px;
    margin-top: 4px;
    transition: background .2s, color .2s;
}
#to-new-chat-btn:hover { background: #1b47a0; color: #fff; }

/* Indicador de escritura */
.to-typing { display: flex; align-items: center; gap: 4px; padding: 4px 0; }
.to-typing span {
    width: 6px; height: 6px;
    background: #aaa;
    border-radius: 50%;
    animation: toDot .9s infinite;
}
.to-typing span:nth-child(2) { animation-delay: .15s; }
.to-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes toDot { 0%,60%,100%{transform:translateY(0)} 30%{transform:translateY(-5px)} }

/* Responsive */
@media (max-width: 400px) {
    #to-chat-window { width: calc(100vw - 32px); right: 0; }
    #to-chat-widget { right: 16px; bottom: 16px; }
}

/* ── Bot SANTI ──────────────────────────────────────────────── */
.to-bot-label {
    font-size: 10px;
    color: #4fb0ff;
    opacity: .8;
    margin-bottom: 2px;
    display: block;
}
.to-bubble.bot {
    background: linear-gradient(135deg, #0c2c66 0%, #0a1a40 100%);
    border: 1px solid rgba(79,176,255,.3);
    color: #c8deff;
    white-space: pre-wrap;
}
