/* AI Event Planning Assistant — Chat Panel
 * @since 5.35.63
 * Brand: Midnight Reserve #111111, Toasted Sand #cfaf86, Smoked Merlot #111111
 *        Bronzed Cocoa #7B563A, Ivory Mist #F9F6F2
 */

.cbt-ai-assistant-wrap {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 200px);
    min-height: 480px;
    max-height: 800px;
    background: #F9F6F2;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #e5e1da;
}

/* Header */
.cbt-ai-header {
    padding: 16px 24px;
    background: #fff;
    border-bottom: 1px solid #e5e1da;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
.cbt-ai-header-left h2 {
    font-size: 16px;
    font-weight: 600;
    color: #111111;
    margin: 0;
}
.cbt-ai-header-left .cbt-ai-subtitle {
    font-size: 12px;
    color: #7B563A;
    margin-top: 2px;
}
.cbt-ai-status {
    font-size: 11px;
    background: #e8f5e9;
    color: #2e7d32;
    padding: 4px 10px;
    border-radius: 20px;
}
.cbt-ai-usage {
    font-size: 11px;
    color: #999;
    margin-left: 8px;
}

/* Messages area */
.cbt-ai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.cbt-ai-messages::-webkit-scrollbar { width: 6px; }
.cbt-ai-messages::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }

/* Message bubbles */
.cbt-ai-msg {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    max-width: 100%;
}
.cbt-ai-msg.cbt-ai-msg-user {
    justify-content: flex-end;
}
.cbt-ai-msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 12px;
    font-weight: 600;
}
.cbt-ai-msg-avatar.ai {
    background: #111111;
    color: #cfaf86;
}
.cbt-ai-msg-avatar.user {
    background: #111111;
    color: #fff;
}
.cbt-ai-msg-bubble {
    border-radius: 12px;
    padding: 14px 18px;
    max-width: 480px;
    line-height: 1.6;
    font-size: 14px;
    word-wrap: break-word;
}
.cbt-ai-msg-assistant .cbt-ai-msg-bubble {
    background: #fff;
    color: #111111;
    border: 1px solid #e5e1da;
}
.cbt-ai-msg-user .cbt-ai-msg-bubble {
    background: #111111;
    color: #fff;
}
.cbt-ai-msg-bubble p {
    margin: 0 0 8px;
}
.cbt-ai-msg-bubble p:last-child {
    margin-bottom: 0;
}

/* Suggestion chips */
.cbt-ai-suggestions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}
.cbt-ai-chip {
    font-size: 12px;
    background: #F9F6F2;
    border: 1px solid #e5e1da;
    padding: 6px 14px;
    border-radius: 20px;
    color: #7B563A;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    white-space: nowrap;
}
.cbt-ai-chip:hover {
    background: #f0ece5;
    border-color: #cfaf86;
}

/* Typing indicator */
.cbt-ai-typing {
    display: none;
    gap: 10px;
    align-items: flex-start;
}
.cbt-ai-typing.active {
    display: flex;
}
.cbt-ai-typing-dots {
    background: #fff;
    border: 1px solid #e5e1da;
    border-radius: 12px;
    padding: 14px 18px;
    display: flex;
    gap: 4px;
    align-items: center;
}
.cbt-ai-typing-dots span {
    width: 6px;
    height: 6px;
    background: #cfaf86;
    border-radius: 50%;
    animation: cbt-ai-bounce 1.2s infinite ease-in-out;
}
.cbt-ai-typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.cbt-ai-typing-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes cbt-ai-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

/* Welcome message */
.cbt-ai-welcome {
    text-align: center;
    padding: 40px 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.cbt-ai-welcome-icon {
    width: 56px;
    height: 56px;
    background: #111111;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}
.cbt-ai-welcome-icon i {
    font-size: 24px;
    color: #cfaf86;
}
.cbt-ai-welcome h3 {
    font-size: 18px;
    color: #111111;
    margin: 0 0 8px;
    font-weight: 600;
}
.cbt-ai-welcome p {
    font-size: 14px;
    color: #7B563A;
    margin: 0 0 20px;
    max-width: 360px;
}
.cbt-ai-welcome-chips {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

/* Input area */
.cbt-ai-input-area {
    padding: 16px 24px;
    background: #fff;
    border-top: 1px solid #e5e1da;
    flex-shrink: 0;
}
.cbt-ai-input-row {
    display: flex;
    gap: 10px;
    align-items: center;
}
.cbt-ai-input-row textarea {
    flex: 1;
    background: #F9F6F2;
    border: 1px solid #e5e1da;
    border-radius: 24px;
    padding: 10px 18px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    min-height: 42px;
    max-height: 120px;
    line-height: 1.4;
    color: #333;
    outline: none;
    transition: border-color 0.15s;
    overflow-y: auto;
}
.cbt-ai-input-row textarea:focus {
    border-color: #cfaf86;
}
.cbt-ai-input-row textarea::placeholder {
    color: #aaa;
}
.cbt-ai-send-btn {
    width: 40px;
    height: 40px;
    background: #111111;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: opacity 0.15s;
}
.cbt-ai-send-btn:hover { opacity: 0.85; }
.cbt-ai-send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.cbt-ai-send-btn i {
    color: #cfaf86;
    font-size: 16px;
}
.cbt-ai-footer-note {
    font-size: 11px;
    color: #999;
    text-align: center;
    margin-top: 8px;
}

/* Error toast */
.cbt-ai-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 13px;
    text-align: center;
    margin: 0 24px;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .cbt-ai-assistant-wrap {
        height: calc(100vh - 160px);
        border-radius: 0;
    }
    .cbt-ai-header { padding: 12px 16px; }
    .cbt-ai-messages { padding: 16px; }
    .cbt-ai-input-area { padding: 12px 16px; }
    .cbt-ai-msg-bubble { max-width: 300px; }
    .cbt-ai-welcome { padding: 20px 16px; }
    .cbt-ai-header-actions { gap: 4px; }
    .cbt-ai-action-btn { width: 32px; height: 32px; font-size: 12px; }
}
@media (max-width: 480px) {
    .cbt-ai-msg-bubble { max-width: 240px; font-size: 13px; }
    .cbt-ai-chip { font-size: 11px; padding: 5px 10px; }
}

/* Header action buttons */
.cbt-ai-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}
.cbt-ai-action-btn {
    width: 36px;
    height: 36px;
    border: 1px solid #e5e1da;
    background: #F9F6F2;
    border-radius: 8px;
    color: #7B563A;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, border-color 0.15s;
}
.cbt-ai-action-btn:hover {
    background: #f0ece5;
    border-color: #cfaf86;
    color: #111111;
}

/* History panel */
.cbt-ai-history-panel {
    position: absolute;
    top: 0;
    left: 0;
    width: 280px;
    height: 100%;
    background: #fff;
    border-right: 1px solid #e5e1da;
    z-index: 10;
    transform: translateX(-100%);
    transition: transform 0.25s ease, visibility 0.25s;
    display: flex;
    flex-direction: column;
    visibility: hidden;
    pointer-events: none;
}
.cbt-ai-history-panel.open {
    transform: translateX(0);
    visibility: visible;
    pointer-events: auto;
}
.cbt-ai-assistant-wrap {
    position: relative;
    overflow: hidden;
}
.cbt-ai-history-header {
    padding: 16px;
    border-bottom: 1px solid #e5e1da;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.cbt-ai-history-header h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: #111111;
}
.cbt-ai-history-close {
    background: none;
    border: none;
    color: #999;
    font-size: 16px;
    cursor: pointer;
    padding: 4px;
}
.cbt-ai-history-close:hover { color: #111111; }
.cbt-ai-history-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}
.cbt-ai-history-loading,
.cbt-ai-history-empty {
    padding: 20px;
    text-align: center;
    font-size: 13px;
    color: #999;
}
.cbt-ai-history-item {
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.1s;
    position: relative;
}
.cbt-ai-history-item:hover {
    background: #F9F6F2;
}
.cbt-ai-history-item.active {
    background: #f0ece5;
    border-left: 3px solid #cfaf86;
}
.cbt-ai-history-item-title {
    flex: 1;
    font-size: 13px;
    color: #111111;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cbt-ai-history-item-meta {
    font-size: 11px;
    color: #999;
    white-space: nowrap;
}
.cbt-ai-history-delete {
    background: none;
    border: none;
    color: #ccc;
    font-size: 12px;
    cursor: pointer;
    padding: 4px;
    opacity: 0;
    transition: opacity 0.15s;
}
.cbt-ai-history-item:hover .cbt-ai-history-delete { opacity: 1; }
.cbt-ai-history-delete:hover { color: #dc2626; }

/* Toast notification */
.cbt-ai-toast {
    position: absolute;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #111111;
    color: #cfaf86;
    padding: 8px 18px;
    border-radius: 20px;
    font-size: 13px;
    opacity: 0;
    transition: opacity 0.25s, transform 0.25s;
    pointer-events: none;
    z-index: 20;
    white-space: nowrap;
}
.cbt-ai-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Streaming cursor — blinking caret while AI is typing */
.cbt-ai-stream-cursor {
    display: inline-block;
    width: 2px;
    height: 16px;
    background: #cfaf86;
    margin-left: 2px;
    vertical-align: text-bottom;
    animation: cbt-ai-cursor-blink 0.6s infinite;
}
@keyframes cbt-ai-cursor-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}
.cbt-ai-streaming .cbt-ai-stream-text p {
    display: inline;
}
.cbt-ai-streaming .cbt-ai-stream-text p + p::before {
    content: "\A\A";
    white-space: pre;
}
