/* ==========================================================================
   Chatbot Widget
   ========================================================================== */

/* FAB Button */
.chatbot-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--gradient-primary);
    color: var(--white);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(4, 107, 210, 0.4);
    z-index: 9998;
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}
.chatbot-fab:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(4, 107, 210, 0.5);
}
.chatbot-fab.hidden {
    transform: scale(0);
    opacity: 0;
    pointer-events: none;
}

/* Panel */
.chatbot-panel {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 380px;
    height: 560px;
    background: var(--white);
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.18);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.8) translateY(20px);
    opacity: 0;
    pointer-events: none;
    transition: all 0.25s ease;
    transform-origin: bottom right;
}
.chatbot-panel.active {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: auto;
}

/* Header */
.chatbot-header {
    background: var(--gradient-primary);
    color: var(--white);
    padding: 1rem 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    cursor: grab;
}
.chatbot-header:active {
    cursor: grabbing;
}

/* Dragging state */
.chatbot-panel.dragging {
    transition: none;
    user-select: none;
}

/* Resize Handles */
.chatbot-resize {
    position: absolute;
    z-index: 10;
}
.chatbot-resize-n  { top: -3px; left: 8px; right: 8px; height: 6px; cursor: n-resize; }
.chatbot-resize-s  { bottom: -3px; left: 8px; right: 8px; height: 6px; cursor: s-resize; }
.chatbot-resize-e  { right: -3px; top: 8px; bottom: 8px; width: 6px; cursor: e-resize; }
.chatbot-resize-w  { left: -3px; top: 8px; bottom: 8px; width: 6px; cursor: w-resize; }
.chatbot-resize-ne { top: -3px; right: -3px; width: 12px; height: 12px; cursor: ne-resize; }
.chatbot-resize-nw { top: -3px; left: -3px; width: 12px; height: 12px; cursor: nw-resize; }
.chatbot-resize-se { bottom: -3px; right: -3px; width: 12px; height: 12px; cursor: se-resize; }
.chatbot-resize-sw { bottom: -3px; left: -3px; width: 12px; height: 12px; cursor: sw-resize; }
.chatbot-header-info {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-weight: 600;
}
.chatbot-header-info i {
    font-size: 1.2rem;
}
.chatbot-header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.chatbot-clear,
.chatbot-close {
    background: none;
    border: none;
    color: var(--white);
    cursor: pointer;
    font-size: 1.1rem;
    padding: 0.25rem;
    opacity: 0.8;
}
.chatbot-clear:hover,
.chatbot-close:hover {
    opacity: 1;
}

/* Messages */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.chatbot-msg {
    max-width: 85%;
}
.chatbot-msg.user {
    align-self: flex-end;
}
.chatbot-msg.bot {
    align-self: flex-start;
}

.chatbot-msg-content {
    padding: 0.75rem 1rem;
    border-radius: 12px;
    line-height: 1.6;
    font-size: 0.9rem;
}
.chatbot-msg.user .chatbot-msg-content {
    background: var(--primary-color);
    color: var(--white);
    border-bottom-right-radius: 4px;
}
.chatbot-msg.bot .chatbot-msg-content {
    background: var(--bg-light);
    color: var(--text-dark);
    border-bottom-left-radius: 4px;
}

/* Links */
.chatbot-link {
    color: var(--primary-color);
    text-decoration: underline;
    word-break: break-all;
}
.chatbot-link:hover {
    opacity: 0.8;
}

/* Typing Indicator */
.typing-indicator {
    display: inline-flex;
    gap: 4px;
    padding: 4px 0;
}
.typing-indicator span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-light);
    animation: typingBounce 1.4s infinite ease-in-out both;
}
.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }
@keyframes typingBounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Suggestions */
.chatbot-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.5rem;
}
.suggestion-chip {
    background: var(--white);
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    border-radius: 16px;
    padding: 0.3rem 0.75rem;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: inherit;
}
.suggestion-chip:hover {
    background: var(--primary-color);
    color: var(--white);
}

/* Feedback */
.chatbot-feedback {
    display: flex;
    gap: 0.4rem;
    margin-top: 0.3rem;
}
.fb-btn {
    background: none;
    border: 1px solid #ddd;
    border-radius: 16px;
    padding: 0.2rem 0.5rem;
    cursor: pointer;
    font-size: 0.75rem;
    color: var(--text-light);
    transition: all 0.15s;
}
.fb-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}
.fb-thanks {
    font-size: 0.75rem;
    color: var(--success);
}

/* Quote Submit */
.chatbot-quote-card {
    margin-top: 0.75rem;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
    background: #f8fafc;
}
.chatbot-quote-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}
.chatbot-quote-table th {
    width: 80px;
    padding: 6px 10px;
    background: #edf2f7;
    color: #4a5568;
    font-weight: 600;
    text-align: left;
    white-space: nowrap;
    border-bottom: 1px solid #e2e8f0;
}
.chatbot-quote-table td {
    padding: 6px 10px;
    color: #1a202c;
    border-bottom: 1px solid #e2e8f0;
    word-break: break-all;
}
.chatbot-quote-table tr:last-child th,
.chatbot-quote-table tr:last-child td {
    border-bottom: none;
}
.chatbot-quote-submit {
    display: block;
    width: 100%;
    background: var(--success);
    color: var(--white);
    border: none;
    border-top: 1px solid #e2e8f0;
    padding: 0.6rem 1.2rem;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    font-family: inherit;
    transition: all 0.15s;
}
.chatbot-quote-submit:hover {
    opacity: 0.9;
}

/* Input Area */
.chatbot-input-area {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-top: 1px solid #eee;
    flex-shrink: 0;
}
.chatbot-input-area textarea {
    flex: 1;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 0.6rem 1rem;
    font-size: 0.9rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s;
    resize: vertical;
    min-height: 40px;
    max-height: 120px;
    line-height: 1.4;
    overflow-y: auto;
}
.chatbot-input-area textarea:focus {
    border-color: var(--primary-color);
}
.chatbot-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--gradient-primary);
    color: var(--white);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    transition: all 0.15s;
    flex-shrink: 0;
}
.chatbot-send:hover {
    opacity: 0.9;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .chatbot-panel {
        bottom: 0 !important;
        right: 0 !important;
        left: 0 !important;
        top: 0 !important;
        width: 100% !important;
        height: 100% !important;
        border-radius: 0;
        transform-origin: bottom center;
    }
    .chatbot-panel.active {
        border-radius: 0;
    }
    .chatbot-fab {
        bottom: 16px;
        right: 16px;
    }
    .chatbot-header {
        cursor: default;
    }
    .chatbot-resize {
        display: none;
    }
}
