/* COLPAGE Chat Widget — Frontend */

#colpage-chat-root {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.4;
}

/* ── FAB ── */
#colpage-chat-fab {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #6366f1;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 18px rgba(99,102,241,.5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    outline: none;
    transition: transform .2s ease, box-shadow .2s ease;
}

#colpage-chat-fab:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(99,102,241,.6);
}

.colpage-fab-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
}

.colpage-fab-icon svg {
    width: 26px;
    height: 26px;
    fill: #fff;
    display: block;
    pointer-events: none;
}

/* ── Panel ── */
#colpage-chat-panel {
    position: absolute;
    bottom: 68px;
    right: 0;
    width: 320px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0,0,0,.18), 0 2px 8px rgba(0,0,0,.08);
    overflow: hidden;
    animation: colpage-chat-slidein .2s ease;
}

@keyframes colpage-chat-slidein {
    from { opacity: 0; transform: translateY(10px) scale(.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Header ── */
.colpage-chat-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 16px;
    background: #6366f1;
}

.colpage-chat-title {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    flex: 1;
}

.colpage-chat-btn-icon {
    background: none;
    border: none;
    color: rgba(255,255,255,.75);
    cursor: pointer;
    padding: 3px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: color .15s, background .15s;
}

.colpage-chat-btn-icon:hover {
    color: #fff;
    background: rgba(255,255,255,.18);
}

.colpage-chat-btn-icon svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
    display: block;
}

/* ── Channel selection ── */
.colpage-channel-list {
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.colpage-channel-btn {
    display: flex;
    align-items: center;
    gap: 13px;
    padding: 13px 14px;
    border: 1.5px solid #e5e7eb;
    border-radius: 12px;
    background: #fff;
    cursor: pointer;
    font-family: inherit;
    text-align: left;
    width: 100%;
    transition: border-color .15s, background .15s, box-shadow .15s;
}

.colpage-channel-btn:hover {
    border-color: #6366f1;
    background: #f5f3ff;
    box-shadow: 0 2px 8px rgba(99,102,241,.12);
}

.colpage-channel-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.colpage-channel-icon svg {
    width: 22px;
    height: 22px;
    display: block;
}

.colpage-channel-icon--web { background: #ede9fe; }
.colpage-channel-icon--web svg { fill: #6366f1; }

.colpage-channel-icon--wpp { background: #dcfce7; }
.colpage-channel-icon--wpp svg { fill: #16a34a; }

.colpage-channel-label {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.colpage-channel-label strong {
    font-size: 14px;
    font-weight: 600;
    color: #111827;
}

.colpage-channel-label small {
    font-size: 12px;
    color: #6b7280;
}

/* ── Messages ── */
#colpage-chat-messages {
    height: 260px;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: #f8fafc;
    scroll-behavior: smooth;
}

.colpage-chat-empty {
    margin: auto;
    color: #9ca3af;
    font-size: 13px;
    text-align: center;
}

.colpage-msg {
    display: flex;
    max-width: 82%;
}

.colpage-msg span {
    padding: 8px 12px;
    border-radius: 14px;
    font-size: 13px;
    line-height: 1.5;
    word-break: break-word;
}

.colpage-msg-user {
    align-self: flex-end;
}

.colpage-msg-user span {
    background: #6366f1;
    color: #fff;
    border-bottom-right-radius: 3px;
}

.colpage-msg-bot span {
    background: #fff;
    color: #1f2937;
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 3px;
}

/* ── Typing indicator ── */
.colpage-typing {
    display: inline-flex !important;
    align-items: center;
    gap: 4px;
    padding: 10px 14px !important;
}

.colpage-typing span {
    display: inline-block !important;
    width: 6px !important;
    height: 6px !important;
    background: #9ca3af !important;
    border-radius: 50% !important;
    padding: 0 !important;
    border: none !important;
    animation: colpage-chat-bounce .9s ease-in-out infinite;
}

.colpage-typing span:nth-child(2) { animation-delay: .15s; }
.colpage-typing span:nth-child(3) { animation-delay: .3s;  }

@keyframes colpage-chat-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30%            { transform: translateY(-5px); }
}

/* ── Input row ── */
.colpage-chat-input-row {
    display: flex;
    gap: 6px;
    padding: 10px 12px;
    border-top: 1px solid #e5e7eb;
    background: #fff;
}

#colpage-chat-input {
    flex: 1;
    min-width: 0;
    border: 1.5px solid #d1d5db;
    border-radius: 8px;
    padding: 8px 11px;
    font-size: 13px;
    font-family: inherit;
    color: #111827;
    background: #fff;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}

#colpage-chat-input:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99,102,241,.12);
}

#colpage-chat-input:disabled { opacity: .6; cursor: not-allowed; }

#colpage-chat-send-btn {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    background: #6366f1;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background .15s;
}

#colpage-chat-send-btn:hover    { background: #4f46e5; }
#colpage-chat-send-btn:disabled { opacity: .6; cursor: not-allowed; }

#colpage-chat-send-btn svg {
    width: 18px;
    height: 18px;
    fill: #fff;
    display: block;
}

/* ── Mobile ── */
@media (max-width: 420px) {
    #colpage-chat-root  { bottom: 16px; right: 16px; }
    #colpage-chat-panel { width: calc(100vw - 32px); }
}
