/* Chatbot Widget Styles */
#chatbot-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: 'Jost', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Floating trigger button */
.chatbot-trigger {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0C172F 0%, #1e3a5f 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(12, 23, 47, 0.35);
    transition: all 0.3s ease;
    border: none;
}

.chatbot-trigger:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 25px rgba(12, 23, 47, 0.45);
}

.chatbot-trigger.active {
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
}

.chatbot-trigger svg {
    transition: transform 0.3s ease;
}

.chatbot-trigger.active svg {
    transform: rotate(90deg);
}

/* Chat container */
.chatbot-container {
    position: absolute;
    bottom: 70px;
    right: 0;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 520px;
    max-height: calc(100vh - 100px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: chatbotSlideUp 0.3s ease;
}

/* Main chat body - wraps messages and quick replies */
.chatbot-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

@keyframes chatbotSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Header */
.chatbot-header {
    background: linear-gradient(135deg, #0C172F 0%, #1e3a5f 100%);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.chatbot-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chatbot-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
}

.chatbot-avatar svg {
    color: #fff;
}

.chatbot-header-info h6 {
    font-size: 0.95rem;
    font-weight: 600;
    margin: 0;
}

.chatbot-status {
    font-size: 0.75rem;
    opacity: 0.85;
    display: flex;
    align-items: center;
    gap: 5px;
}

.chatbot-status::before {
    content: '';
    width: 7px;
    height: 7px;
    background: #22c55e;
    border-radius: 50%;
    display: inline-block;
}

.chatbot-header-actions {
    display: flex;
    gap: 4px;
}

.chatbot-header-btn {
    background: transparent;
    border: none;
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.chatbot-header-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* Messages area */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f8fafc;
    min-height: 0;
}

.chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

.chatbot-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chatbot-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.chatbot-message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 16px;
    line-height: 1.5;
    font-size: 0.9rem;
    animation: messageSlide 0.3s ease;
}

@keyframes messageSlide {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chatbot-message.user {
    align-self: flex-end;
    background: linear-gradient(135deg, #0C172F 0%, #1e3a5f 100%);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.chatbot-message.bot {
    align-self: flex-start;
    background: #fff;
    color: #1e293b;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.chatbot-message p {
    margin: 0;
}

.chatbot-message p + p {
    margin-top: 8px;
}

.chatbot-action-btn {
    display: inline-block;
    margin-top: 10px;
    padding: 8px 14px;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: #fff !important;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    text-decoration: none !important;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chatbot-action-btn:hover {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    transform: translateY(-1px);
}

/* Typing indicator */
.chatbot-typing {
    align-self: flex-start;
    background: #fff;
    padding: 14px 18px;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    display: flex;
    gap: 5px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.chatbot-typing span {
    width: 8px;
    height: 8px;
    background: #94a3b8;
    border-radius: 50%;
    animation: typingBounce 1.4s ease-in-out infinite both;
}

.chatbot-typing span:nth-child(1) { animation-delay: -0.32s; }
.chatbot-typing span:nth-child(2) { animation-delay: -0.16s; }
.chatbot-typing span:nth-child(3) { animation-delay: 0s; }

@keyframes typingBounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

/* Quick replies */
.chatbot-quick-replies {
    padding: 10px 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    background: #fff;
    border-top: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.chatbot-quick-replies:empty {
    display: none;
    padding: 0;
}

.chatbot-quick-reply {
    padding: 7px 14px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    font-size: 0.8rem;
    color: #475569;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    max-width: calc(100% - 28px);
    overflow: hidden;
    text-overflow: ellipsis;
}

.chatbot-quick-reply:hover {
    background: #0C172F;
    border-color: #0C172F;
    color: #fff;
    transform: translateY(-1px);
}

/* Input area */
.chatbot-input-area {
    padding: 12px 16px;
    background: #fff;
    border-top: 1px solid #e2e8f0;
    flex-shrink: 0;
}

#chatbot-form {
    display: flex;
    gap: 8px;
}

#chatbot-input {
    flex: 1;
    padding: 10px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 24px;
    outline: none;
    font-size: 0.9rem;
    transition: border-color 0.2s ease;
    font-family: inherit;
}

#chatbot-input:focus {
    border-color: #3b82f6;
}

#chatbot-input::placeholder {
    color: #94a3b8;
}

.chatbot-send {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0C172F 0%, #1e3a5f 100%);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.chatbot-send:hover {
    background: linear-gradient(135deg, #1e3a5f 0%, #0C172F 100%);
    transform: scale(1.05);
}

.chatbot-send:active {
    transform: scale(0.95);
}

/* Escalate button */
.chatbot-escalate {
    margin-top: 8px;
    text-align: center;
}

.chatbot-escalate button {
    background: transparent;
    border: none;
    color: #64748b;
    font-size: 0.8rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.chatbot-escalate button:hover {
    color: #3b82f6;
    background: #f1f5f9;
}

/* Welcome message */
.chatbot-welcome {
    margin-bottom: 8px;
}

/* Escalation prompt */
.chatbot-escalation-prompt {
    background: #fef3c7 !important;
    border: 1px solid #fcd34d;
}

/* Mobile responsiveness */
@media (max-width: 480px) {
    #chatbot-widget {
        bottom: 10px;
        right: 10px;
    }

    .chatbot-container {
        width: calc(100vw - 20px);
        height: calc(100vh - 80px);
        max-height: none;
        bottom: 65px;
        right: 0;
        border-radius: 12px;
    }

    .chatbot-trigger {
        width: 50px;
        height: 50px;
    }

    .chatbot-message {
        max-width: 90%;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .chatbot-container {
        background: #1e293b;
    }

    .chatbot-messages {
        background: #0f172a;
    }

    .chatbot-message.bot {
        background: #334155;
        color: #e2e8f0;
    }

    .chatbot-quick-replies {
        background: #1e293b;
        border-top-color: #334155;
    }

    .chatbot-quick-reply {
        background: #334155;
        border-color: #475569;
        color: #e2e8f0;
    }

    .chatbot-quick-reply:hover {
        background: #3b82f6;
        border-color: #3b82f6;
        color: #fff;
    }

    .chatbot-body {
        background: #0f172a;
    }

    .chatbot-input-area {
        background: #1e293b;
        border-top-color: #334155;
    }

    #chatbot-input {
        background: #334155;
        border-color: #475569;
        color: #e2e8f0;
    }

    #chatbot-input:focus {
        border-color: #3b82f6;
    }

    .chatbot-escalate button {
        color: #94a3b8;
    }

    .chatbot-escalate button:hover {
        background: #334155;
    }
}
