/* ========================================
   CHATBOT WIDGET
   ======================================== */

.chatbot-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: var(--font-family);
}

/* Chatbot Toggle Button */
.chatbot-toggle {
    width: 60px;
    height: 60px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-xl);
    transition: all var(--transition-base);
    position: relative;
    border: none;
    font-size: var(--font-size-xl);
}

.chatbot-toggle:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-2xl);
}

.chatbot-toggle.chatbot-active {
    background: var(--color-error);
}

.chatbot-notification {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 24px;
    height: 24px;
    background: var(--color-error);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-xs);
    font-weight: 700;
    color: white;
    border: 2px solid white;
}

/* Chatbot Container */
.chatbot-container {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 600px;
    max-height: calc(100vh - 100px);
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-2xl);
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: all var(--transition-base);
    overflow: hidden;
}

.chatbot-container.chatbot-open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Chatbot Header */
.chatbot-header {
    padding: var(--space-5);
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.chatbot-header-info {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex: 1;
}

.chatbot-header-info i {
    font-size: var(--font-size-2xl);
    opacity: 0.9;
}

.chatbot-header-info h3 {
    font-size: var(--font-size-lg);
    font-weight: 700;
    margin: 0;
    line-height: var(--line-height-tight);
}

.chatbot-header-info p {
    font-size: var(--font-size-sm);
    margin: 0;
    opacity: 0.9;
}

.chatbot-close {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: var(--space-2);
    border-radius: var(--radius-md);
    transition: background var(--transition-base);
    font-size: var(--font-size-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
}

.chatbot-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Chatbot Messages */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-5);
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    background: var(--color-bg-secondary);
}

.chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

.chatbot-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chatbot-messages::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: var(--radius-full);
}

.chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: var(--color-border-hover);
}

.chatbot-message {
    display: flex;
    gap: var(--space-3);
    align-items: flex-start;
    animation: fadeIn 0.3s ease-out;
}

.chatbot-message-user {
    justify-content: flex-end;
}

.chatbot-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: var(--font-size-sm);
}

.chatbot-message-user .chatbot-avatar {
    display: none;
}

.chatbot-message-content {
    max-width: 75%;
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-lg);
    line-height: var(--line-height-relaxed);
}

.chatbot-message-bot .chatbot-message-content {
    background: var(--color-bg-tertiary);
    color: var(--color-text-primary);
    border: 1px solid var(--color-border);
}

.chatbot-message-user .chatbot-message-content {
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    color: white;
    border: none;
}

.chatbot-message-content p {
    margin: 0;
    font-size: var(--font-size-sm);
    word-wrap: break-word;
}

/* Chatbot Typing Indicator */
.chatbot-typing {
    display: flex;
    gap: var(--space-2);
    padding: var(--space-4) var(--space-5);
    align-items: center;
}

.chatbot-typing span {
    width: 8px;
    height: 8px;
    border-radius: var(--radius-full);
    background: var(--color-text-tertiary);
    animation: typing 1.4s infinite ease-in-out;
}

.chatbot-typing span:nth-child(2) {
    animation-delay: 0.2s;
}

.chatbot-typing span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.5;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Chatbot Input Container */
.chatbot-input-container {
    padding: var(--space-4);
    background: var(--color-bg-card);
    border-top: 1px solid var(--color-border);
}

.chatbot-form {
    display: flex;
    gap: var(--space-3);
    align-items: center;
}

.chatbot-input {
    flex: 1;
    padding: var(--space-3) var(--space-4);
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text-primary);
    font-size: var(--font-size-sm);
    font-family: var(--font-family);
    transition: all var(--transition-base);
    outline: none;
}

.chatbot-input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.chatbot-input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.chatbot-send {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-base);
    flex-shrink: 0;
}

.chatbot-send:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: var(--shadow-md);
}

.chatbot-send:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Responsive Design */
@media (max-width: 768px) {
    .chatbot-widget {
        bottom: 15px;
        right: 15px;
    }
    
    .chatbot-toggle {
        width: 56px;
        height: 56px;
        font-size: var(--font-size-lg);
    }
    
    .chatbot-container {
        width: calc(100vw - 30px);
        height: calc(100vh - 80px);
        max-height: calc(100vh - 80px);
        bottom: 75px;
        right: 0;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    }
    
    .chatbot-message-content {
        max-width: 85%;
    }
}

@media (max-width: 480px) {
    .chatbot-container {
        width: 100vw;
        height: calc(100vh - 60px);
        max-height: calc(100vh - 60px);
        bottom: 60px;
        right: 0;
        left: 0;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    }
    
    .chatbot-header {
        padding: var(--space-4);
    }
    
    .chatbot-messages {
        padding: var(--space-4);
    }
}

