/* ============================================================
   ChatWidget — visible en vistas públicas (Home, etc.)
   Diseño compacto, no intrusivo, sin dependencias.
   ============================================================ */

.ci-chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9000;
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

.ci-chat-launcher {
    background: #1976d2;
    color: white;
    border: none;
    border-radius: 50%;
    width: 56px;
    height: 56px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: transform 0.15s ease;
}

.ci-chat-launcher:hover { transform: scale(1.05); }

.ci-chat-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: #d32f2f;
    color: white;
    border-radius: 10px;
    padding: 2px 6px;
    font-size: 11px;
    font-weight: bold;
    min-width: 18px;
    text-align: center;
}

.ci-chat-panel {
    width: 360px;
    max-width: calc(100vw - 24px);
    height: 520px;
    max-height: calc(100vh - 40px);
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.25);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.ci-chat-header {
    background: #1976d2;
    color: #fff;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.ci-chat-title { display: flex; flex-direction: column; line-height: 1.15; }
.ci-chat-subtitle { font-size: 12px; opacity: 0.85; }
.ci-chat-close { background: transparent; border: 0; color: #fff; font-size: 22px; cursor: pointer; padding: 0 4px; }

.ci-chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    background: #f5f7fa;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* Cada mensaje apila en columna: burbuja arriba, quick replies abajo. La
   alineación horizontal (left/right/center) se controla con align-items
   según el remitente. */
.ci-chat-msg { display: flex; flex-direction: column; }
.ci-chat-msg.visitor { align-items: flex-end; }
.ci-chat-msg.bot, .ci-chat-msg.agent { align-items: flex-start; }
.ci-chat-msg.system { align-items: center; }

.bubble {
    max-width: 80%;
    padding: 8px 10px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.35;
    word-wrap: break-word;
}

.ci-chat-msg.visitor .bubble {
    background: #1976d2;
    color: #fff;
    border-bottom-right-radius: 4px;
}
.ci-chat-msg.bot .bubble {
    background: #e7eaf3;
    color: #222;
    border-bottom-left-radius: 4px;
}
.ci-chat-msg.agent .bubble {
    background: #c8e6c9;
    color: #1b3e1f;
    border-bottom-left-radius: 4px;
}
.ci-chat-sender { font-weight: 600; font-size: 12px; margin-bottom: 2px; opacity: 0.8; }
.ci-chat-content { white-space: pre-wrap; }
.ci-chat-time { font-size: 10px; opacity: 0.65; margin-top: 2px; text-align: right; }

.ci-chat-system {
    font-size: 12px;
    color: #555;
    background: #ececec;
    border-radius: 10px;
    padding: 6px 10px;
    text-align: center;
    max-width: 90%;
}

.ci-chat-spinner {
    display: inline-block;
    width: 10px;
    height: 10px;
    border: 2px solid #888;
    border-top-color: transparent;
    border-radius: 50%;
    animation: ciChatSpin 0.8s linear infinite;
    margin-right: 6px;
    vertical-align: middle;
}

@keyframes ciChatSpin { to { transform: rotate(360deg); } }

.ci-chat-actions { display: flex; gap: 8px; justify-content: center; margin-top: 8px; flex-wrap: wrap; }
.ci-chat-btn {
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 13px;
    cursor: pointer;
}
.ci-chat-btn.primary { background: #1976d2; color: #fff; border-color: #1976d2; }
.ci-chat-btn:disabled { opacity: 0.55; cursor: not-allowed; }

.ci-chat-form {
    background: #fafbfd;
    border-top: 1px solid #e2e6ec;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.ci-chat-form-title { font-weight: 600; font-size: 13px; color: #333; }
.ci-chat-form input {
    border: 1px solid #ccd;
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 14px;
    outline: none;
}
.ci-chat-form input:focus { border-color: #1976d2; }
.ci-chat-form-error { color: #c62828; font-size: 12px; }

.ci-chat-input {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    background: #fff;
    border-top: 1px solid #e2e6ec;
}
.ci-chat-input input[type="text"] {
    flex: 1;
    border: 1px solid #d0d7de;
    border-radius: 18px;
    padding: 9px 14px;
    font-size: 14px;
    line-height: 1.3;
    outline: none;
    font-family: inherit;
    background: #f5f7fa;
    color: #1f2937;
    transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.03);
    min-width: 0;
}
.ci-chat-input input[type="text"]::placeholder {
    color: #9aa3af;
}
.ci-chat-input input[type="text"]:focus {
    border-color: #1976d2;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.12);
}

.ci-chat-send {
    background: #1976d2;
    color: #fff;
    border: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.ci-chat-send:disabled { background: #b0bec5; cursor: not-allowed; }

.ci-chat-attach {
    background: transparent;
    border: 0;
    color: #555;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.ci-chat-attach:hover { background: #f0f0f0; }

.ci-chat-img {
    display: block;
    max-width: 220px;
    max-height: 220px;
    border-radius: 8px;
    margin: 2px 0;
    cursor: pointer;
}

.ci-chat-upload { font-size: 11px; color: #666; text-align: center; padding: 2px 8px; }
.ci-chat-upload-error { font-size: 11px; color: #c62828; text-align: center; padding: 2px 8px; }

.ci-chat-talk-agent {
    background: transparent;
    border: 0;
    color: #1976d2;
    font-size: 12px;
    padding: 6px;
    cursor: pointer;
    text-align: center;
    width: 100%;
    border-top: 1px solid #f0f0f0;
}
.ci-chat-talk-agent:hover { text-decoration: underline; }

@media (max-width: 480px) {
    .ci-chat-panel { width: calc(100vw - 16px); height: calc(100vh - 80px); }
    .ci-chat-widget { right: 8px; bottom: 8px; }
}

/* ============================================================
   Campana del agente — flotante fija arriba-derecha del admin.
   ============================================================ */

.ci-chat-bell-wrap {
    position: fixed;
    bottom: 20px;
    right: 22px;
    z-index: 8500;
    font-family: 'Segoe UI', Roboto, Arial, sans-serif;
}

.ci-chat-bell {
    background: #fff;
    color: #1976d2;
    border: 1px solid #e2e6ec;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    position: relative;
}
.ci-chat-bell:hover { border-color: #1976d2; }

.ci-chat-bell-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #d32f2f;
    color: #fff;
    border-radius: 10px;
    padding: 1px 6px;
    font-size: 11px;
    font-weight: bold;
    min-width: 18px;
    text-align: center;
}

.ci-chat-bell-dropdown {
    position: absolute;
    bottom: 48px;
    right: 0;
    width: 340px;
    max-width: calc(100vw - 24px);
    max-height: 60vh;
    overflow: auto;
    border: 1px solid #e2e6ec;
    border-radius: 10px;
    box-shadow: 0 -6px 20px rgba(0,0,0,0.15);
}

.ci-chat-bell-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 12px;
    border-bottom: 1px solid #f0f0f0;
}
.ci-chat-bell-close { border: 0; background: transparent; font-size: 18px; cursor: pointer; }
.ci-chat-bell-empty { padding: 16px; color: #777; font-size: 14px; text-align: center; }

.ci-chat-bell-list { list-style: none; margin: 0; padding: 0; }
.ci-chat-bell-list li {
    padding: 10px 12px;
    border-bottom: 1px solid #f4f4f4;
    display: flex; flex-direction: column; gap: 2px;
}
.ci-chat-bell-name { font-weight: 600; font-size: 14px; }
.ci-chat-bell-phone { font-size: 12px; color: #555; }
.ci-chat-bell-preview { font-size: 13px; color: #333; }
.ci-chat-bell-actions { margin-top: 6px; }
.ci-chat-bell-btn {
    background: #1976d2; color: #fff; border: 0;
    padding: 4px 10px; font-size: 12px; border-radius: 6px; cursor: pointer;
}
.ci-chat-bell-btn.primary { background: #1976d2; }
.ci-chat-bell-footer { padding: 10px 12px; text-align: center; border-top: 1px solid #f0f0f0; }
.ci-chat-bell-footer a { color: #1976d2; text-decoration: none; font-size: 13px; }
.ci-chat-bell-footer a:hover { text-decoration: underline; }

/* === Quick replies / botones de selección del bot === */
.ci-chat-quick-replies {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    margin: 6px 0 4px 0;
    max-width: 85%;
    width: fit-content;
}
.ci-chat-quick-reply {
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    padding: 9px 14px;
    border-radius: 14px;
    border: 1px solid #c7d2e6;
    background: #fff;
    color: #1f3a5f;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color .15s ease, border-color .15s ease, transform .1s ease;
    line-height: 1.3;
    text-align: left;
    width: 100%;
}
.ci-chat-quick-reply:hover:not(:disabled) {
    background: #eef3fb;
    border-color: #6b8ed1;
}
.ci-chat-quick-reply:active:not(:disabled) { transform: translateY(1px); }
.ci-chat-quick-reply:disabled { cursor: default; }
.ci-chat-quick-reply.is-disabled {
    opacity: 0.55;
    background: #f5f6f8;
    color: #6b7280;
    border-color: #e0e3ea;
}
.ci-chat-quick-reply.primary {
    background: #1976d2;
    color: #fff;
    border-color: #1976d2;
}
.ci-chat-quick-reply.primary:hover:not(:disabled) {
    background: #1466bb;
    border-color: #1466bb;
}
.ci-chat-quick-reply.ghost {
    background: transparent;
    border-color: #d6dbe4;
    color: #4b5563;
}
.ci-chat-quick-reply.danger {
    background: #fff;
    color: #b42318;
    border-color: #fda29b;
}
.ci-chat-quick-reply i { font-size: 12px; }
