/* ======= CHATBOT WIDGET STYLES ======= */

:root {
    --chatbot-primary: #ad002d;
    --chatbot-primary-dark: #8a0024;
    --chatbot-primary-light: #fff5f7;
    --chatbot-surface: #ffffff;
    --chatbot-text: #2a2a2a;
    --chatbot-text-light: #666;
    --chatbot-border: #ebe8e5;
    --chatbot-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    --chatbot-shadow-lg: 0 12px 48px rgba(0, 0, 0, 0.15);
}

/* Main Widget Container */
.chatbot-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* Floating Toggle Button */
.chatbot-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--chatbot-primary) 0%, var(--chatbot-primary-dark) 100%);
    border: none;
    box-shadow: var(--chatbot-shadow);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.22, 0.61, 0.36, 1);
    position: relative;
    overflow: hidden;
}

.chatbot-toggle:hover {
    transform: scale(1.05);
    box-shadow: var(--chatbot-shadow-lg);
}

.chatbot-toggle:active {
    transform: scale(0.95);
}

.chatbot-toggle svg {
    width: 28px;
    height: 28px;
    color: white;
    transition: all 0.3s ease;
    position: absolute;
}

.chatbot-toggle .icon-chat {
    opacity: 1;
    transform: rotate(0deg);
}

.chatbot-toggle .icon-close {
    opacity: 0;
    transform: rotate(90deg);
}

.chatbot-toggle.open .icon-chat {
    opacity: 0;
    transform: rotate(-90deg);
}

.chatbot-toggle.open .icon-close {
    opacity: 1;
    transform: rotate(0deg);
}

/* Chat Window */
.chatbot-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    max-width: calc(100vw - 48px);
    height: 600px;
    max-height: calc(100vh - 120px);
    background: var(--chatbot-surface);
    border-radius: 16px;
    box-shadow: var(--chatbot-shadow-lg);
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.22, 0.61, 0.36, 1);
    overflow: hidden;
}

.chatbot-window.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Header */
.chatbot-header {
    background: linear-gradient(135deg, var(--chatbot-primary) 0%, var(--chatbot-primary-dark) 100%);
    color: white;
    padding: 18px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: 16px 16px 0 0;
}

.chatbot-header-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.bot-avatar-header {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.bot-avatar-header svg {
    width: 24px;
    height: 24px;
    color: white;
}

.chatbot-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}

.chatbot-status {
    font-size: 12px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 6px;
}

.status-dot {
    width: 6px;
    height: 6px;
    background: #4ade80;
    border-radius: 50%;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.chatbot-minimize {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease;
    padding: 0;
}

.chatbot-minimize:hover {
    background: rgba(255, 255, 255, 0.25);
}

.chatbot-minimize svg {
    width: 20px;
    height: 20px;
    color: white;
}

/* Messages Area */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f7f6;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

.chatbot-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chatbot-messages::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Messages */
.message {
    display: flex;
    flex-direction: column;
    gap: 6px;
    animation: messageSlideIn 0.3s ease;
}

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

.message.user {
    align-items: flex-end;
}

.message.bot {
    align-items: flex-start;
}

.bot-avatar {
    width: 32px;
    height: 32px;
    background: var(--chatbot-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.bot-avatar svg {
    width: 18px;
    height: 18px;
    color: white;
}

.message-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--chatbot-text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0 4px;
}

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

.message.user .message-content {
    background: var(--chatbot-primary);
    color: white;
    border-bottom-right-radius: 4px;
}

.message.bot .message-content {
    background: white;
    color: var(--chatbot-text);
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.message-content.error {
    background: #fee;
    color: #c00;
    border: 1px solid #fcc;
}

.message-content strong {
    font-weight: 600;
}

.message-content em {
    font-style: italic;
}

.message-content a {
    color: #1565c0;
    text-decoration: underline;
}

.message-content a:hover {
    text-decoration: none;
}

/* Welcome Message */
.welcome-message .message-content {
    background: linear-gradient(135deg, var(--chatbot-primary-light) 0%, #ffecf0 100%);
    color: var(--chatbot-text);
    border: 1px solid var(--chatbot-primary);
    border-left-width: 4px;
}

/* Loading Indicator */
.loading-bubble {
    display: flex;
    gap: 6px;
    padding: 16px 20px;
    background: white;
    border-radius: 12px;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.loading-bubble span {
    width: 8px;
    height: 8px;
    background: var(--chatbot-primary);
    border-radius: 50%;
    animation: bounce 1.4s ease-in-out infinite;
}

.loading-bubble span:nth-child(1) {
    animation-delay: -0.32s;
}

.loading-bubble span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes bounce {
    0%, 80%, 100% {
        transform: scale(0);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Input Area */
.chatbot-input-area {
    display: flex;
    gap: 12px;
    padding: 16px 20px;
    background: white;
    border-top: 1px solid var(--chatbot-border);
}

.chatbot-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--chatbot-border);
    border-radius: 24px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: all 0.2s ease;
}

.chatbot-input:focus {
    border-color: var(--chatbot-primary);
    box-shadow: 0 0 0 3px rgba(173, 0, 45, 0.1);
}

.chatbot-input::placeholder {
    color: #999;
}

.chatbot-send {
    width: 44px;
    height: 44px;
    background: var(--chatbot-primary);
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.chatbot-send:hover:not(:disabled) {
    background: var(--chatbot-primary-dark);
    transform: scale(1.05);
}

.chatbot-send:active:not(:disabled) {
    transform: scale(0.95);
}

.chatbot-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.chatbot-send svg {
    width: 20px;
    height: 20px;
    color: white;
}

/* Footer */
.chatbot-footer {
    padding: 10px 20px;
    text-align: center;
    font-size: 11px;
    color: var(--chatbot-text-light);
    background: #fafafa;
    border-top: 1px solid var(--chatbot-border);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .chatbot-widget {
        bottom: 16px;
        right: 16px;
        left: 16px;
    }
    
    .chatbot-toggle {
        width: 56px;
        height: 56px;
        position: absolute;
        right: 0;
        bottom: 0;
    }
    
    .chatbot-toggle svg {
        width: 24px;
        height: 24px;
    }
    
    .chatbot-window {
        width: 100%;
        max-width: none;
        height: calc(100vh - 100px);
        bottom: 72px;
        right: auto;
        left: 0;
    }
    
    .message-content {
        max-width: 90%;
    }
}

@media (max-width: 480px) {
    .chatbot-window {
        height: calc(100vh - 80px);
        bottom: 0;
        border-radius: 16px 16px 0 0;
    }
    
    .chatbot-toggle {
        bottom: 16px;
    }
    
    .chatbot-window.open ~ .chatbot-toggle {
        display: none;
    }
}
