/* CloudWorx CX Chat Widget - Floating Assistant */

/* ========== FLOATING BUBBLE (MINIMIZED) ========== */
.chat-bubble {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: linear-gradient(135deg, #003d5c 0%, #0088cc 100%);
    box-shadow: 0 6px 20px rgba(0, 61, 92, 0.4);
    cursor: pointer;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.chat-bubble:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 25px rgba(0, 61, 92, 0.6);
}

.chat-bubble-icon {
    font-size: 32px;
    color: white;
}

.chat-bubble-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #c8a500;
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    font-size: 12px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ========== CHAT WINDOW (EXPANDED) ========== */
.chat-window {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 420px;
    height: 600px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    z-index: 10001;
    display: none;
    flex-direction: column;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.chat-window.open {
    display: flex;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========== CHAT HEADER ========== */
.chat-header {
    background: linear-gradient(135deg, #003d5c 0%, #0088cc 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.chat-header-title {
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-header-title::before {
    content: '💬';
    font-size: 20px;
}

.chat-header-controls {
    display: flex;
    gap: 8px;
}

.chat-header-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.chat-header-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ========== TRACE CONTEXT BAR ========== */
.chat-context-bar {
    background: #fff8e1;
    border-left: 4px solid #c8a500;
    padding: 10px 16px;
    font-size: 12px;
    color: #5d4e37;
    flex-shrink: 0;
}

.chat-context-bar strong {
    color: #003d5c;
}

.chat-context-btn {
    background: #c8a500;
    color: white;
    border: none;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    margin-top: 6px;
    transition: background 0.2s;
}

.chat-context-btn:hover {
    background: #a68900;
}

/* ========== CHAT MESSAGES AREA ========== */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.chat-message.user {
    background: #e3f2fd;
    color: #0d47a1;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.chat-message.assistant {
    background: white;
    color: #333;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.chat-message.system {
    background: #fff3cd;
    color: #856404;
    align-self: center;
    font-size: 12px;
    padding: 8px 12px;
}

/* Message timestamp */
.chat-message-time {
    font-size: 10px;
    color: #999;
    margin-top: 6px;
    text-align: right;
}

/* Typing indicator */
.chat-typing {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: white;
    border-radius: 12px;
    align-self: flex-start;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.chat-typing-dot {
    width: 8px;
    height: 8px;
    background: #0088cc;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out;
}

.chat-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.chat-typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typingBounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* ========== SOURCE CITATIONS ========== */
.chat-sources {
    margin-top: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.chat-source-pill {
    background: linear-gradient(135deg, #c8a500 0%, #d4af37 100%);
    color: white;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.chat-source-pill:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(200, 165, 0, 0.4);
}

/* ========== FOLLOW-UP SUGGESTIONS ========== */
.chat-suggestions {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.chat-suggestion-btn {
    background: #e8f4f8;
    border: 1px solid #0088cc;
    color: #0088cc;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 12px;
    cursor: pointer;
    text-align: left;
    transition: background 0.2s, color 0.2s;
}

.chat-suggestion-btn:hover {
    background: #0088cc;
    color: white;
}

/* ========== QUICK ACTIONS ========== */
.chat-quick-actions {
    background: white;
    padding: 10px 16px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    flex-shrink: 0;
}

.chat-quick-action {
    background: #f0f0f0;
    border: none;
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 11px;
    color: #555;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.chat-quick-action:hover {
    background: #003d5c;
    color: white;
}

/* ========== INPUT AREA ========== */
.chat-input-area {
    background: white;
    padding: 12px 16px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 10px;
    align-items: flex-end;
    flex-shrink: 0;
}

.chat-input {
    flex: 1;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 14px;
    resize: none;
    min-height: 20px;
    max-height: 100px;
    font-family: inherit;
    transition: border-color 0.2s;
}

.chat-input:focus {
    outline: none;
    border-color: #0088cc;
}

.chat-input::placeholder {
    color: #aaa;
}

.chat-send-btn {
    background: linear-gradient(135deg, #003d5c 0%, #0088cc 100%);
    color: white;
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
    flex-shrink: 0;
}

.chat-send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 136, 204, 0.4);
}

.chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ========== MARKDOWN RENDERING ========== */
.chat-message.assistant h1,
.chat-message.assistant h2,
.chat-message.assistant h3 {
    color: #003d5c;
    margin: 12px 0 8px 0;
}

.chat-message.assistant h2 {
    font-size: 16px;
    border-bottom: 2px solid #c8a500;
    padding-bottom: 4px;
}

.chat-message.assistant h3 {
    font-size: 14px;
    color: #0088cc;
}

.chat-message.assistant strong {
    color: #003d5c;
    font-weight: 600;
}

.chat-message.assistant code {
    background: #f4f4f4;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    color: #d63384;
}

.chat-message.assistant pre {
    background: #263238;
    color: #aed581;
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 10px 0;
}

.chat-message.assistant pre code {
    background: none;
    color: inherit;
    padding: 0;
}

.chat-message.assistant ul,
.chat-message.assistant ol {
    margin: 8px 0;
    padding-left: 20px;
}

.chat-message.assistant li {
    margin-bottom: 4px;
}

.chat-message.assistant table {
    width: 100%;
    border-collapse: collapse;
    margin: 10px 0;
    font-size: 12px;
}

.chat-message.assistant th {
    background: #003d5c;
    color: white;
    padding: 8px;
    text-align: left;
}

.chat-message.assistant td {
    padding: 6px 8px;
    border-bottom: 1px solid #ddd;
}

.chat-message.assistant tr:nth-child(even) {
    background: #f9f9f9;
}

/* ========== SESSION SELECTOR ========== */
.chat-session-selector {
    background: #f0f0f0;
    padding: 8px 16px;
    border-bottom: 1px solid #ddd;
    font-size: 12px;
    flex-shrink: 0;
}

.chat-session-select {
    width: 100%;
    padding: 6px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 12px;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 480px) {
    .chat-window {
        width: calc(100vw - 20px);
        height: calc(100vh - 100px);
        bottom: 10px;
        right: 10px;
    }
    
    .chat-bubble {
        bottom: 20px;
        right: 20px;
    }
}


/* ========== RESIZABLE WINDOW ========== */
.chat-window {
    resize: both;
    overflow: hidden;
    min-width: 350px;
    min-height: 400px;
    max-width: 90vw;
    max-height: 90vh;
}

.chat-window-resizer {
    position: absolute;
    top: 0;
    left: 0;
    width: 20px;
    height: 20px;
    cursor: nwse-resize;
    background: linear-gradient(315deg, transparent 50%, #c8a500 50%);
    border-radius: 16px 0 0 0;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.chat-window-resizer:hover {
    opacity: 1;
}

/* Adjust chat window for better resize behavior */
.chat-window.open {
    display: flex;
    position: fixed;
}


/* ========== COPY CODE BUTTON ========== */
.chat-code-wrapper {
    position: relative;
    margin: 10px 0;
}

.chat-copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #aed581;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: -apple-system, BlinkMacSystemFont, sans-serif;
    z-index: 10;
}

.chat-copy-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    color: white;
}

.chat-copy-btn.copied {
    background: #4caf50;
    color: white;
    border-color: #4caf50;
}


/* Fix: Add padding so copy button doesn't cover code text */
.chat-code-wrapper pre {
    padding-top: 35px !important;  /* Make room for button */
}


/* ========== DELETE SESSION BUTTON ========== */
.chat-session-selector {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-session-selector select {
    flex: 1;
}

.chat-delete-session-btn {
    background: #ffebee;
    border: 1px solid #ef5350;
    color: #c62828;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.chat-delete-session-btn:hover {
    background: #ef5350;
    color: white;
}


/* Command Dropdown Selector */
.chat-command-select {
    width: 85px;
    padding: 8px 4px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 11px;
    background: #f8f8f8;
    color: #666;
    cursor: pointer;
    flex-shrink: 0;
    transition: border-color 0.2s, background 0.2s;
}

.chat-command-select:hover {
    border-color: #c8a500;
    background: #fff;
}

.chat-command-select:focus {
    outline: none;
    border-color: #003d5c;
    background: #fff;
}

.chat-command-select option {
    font-size: 12px;
}
