/* Chatbot Frontend Styles */
.chatbot-widget {
    position: fixed;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    font-size: 14px;
    line-height: 1.4;
}

/* Widget positioning */
.chatbot-widget[data-position="bottom-right"] {
    bottom: 20px;
    right: 20px;
}

.chatbot-widget[data-position="bottom-left"] {
    bottom: 20px;
    left: 20px;
}

.chatbot-widget[data-position="top-right"] {
    top: 20px;
    right: 20px;
}

.chatbot-widget[data-position="top-left"] {
    top: 20px;
    left: 20px;
}

/* Toggle Button */
.chatbot-toggle {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--chatbot-primary, #3B82F6);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.chatbot-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

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

.chatbot-toggle .chatbot-icon,
.chatbot-toggle .close-icon {
    transition: all 0.3s ease;
}

.chatbot-toggle.active .chatbot-icon {
    display: none;
}

.chatbot-toggle.active .close-icon {
    display: block !important;
}

/* Notification Badge */
.chatbot-notification {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ef4444;
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-5px);
    }
    60% {
        transform: translateY(-3px);
    }
}

/* Chat Window */
.chatbot-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 500px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    display: flex;
    flex-direction: column;
}

.chatbot-window.show {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* Header */
.chatbot-header {
    padding: 16px;
    background: var(--chatbot-primary, #3B82F6);
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

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

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

.chatbot-name {
    font-weight: 600;
    font-size: 14px;
}

.chatbot-status {
    font-size: 12px;
    opacity: 0.9;
}

.chatbot-actions {
    display: flex;
    gap: 8px;
}

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

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

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

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

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

.chatbot-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 2px;
}

/* Messages */
.chatbot-message {
    display: flex;
    gap: 8px;
    animation: fadeInUp 0.3s ease;
}

.chatbot-message.user-message {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 4px;
}

.user-message .message-avatar {
    background: #e2e8f0;
    color: #64748b;
}

.message-content {
    max-width: 280px;
    flex: 1;
}

.message-text {
    background: white;
    padding: 12px 16px;
    border-radius: 18px;
    border: 1px solid #e2e8f0;
    color: #1e293b;
    word-wrap: break-word;
    line-height: 1.5;
}

.user-message .message-text {
    background: var(--chatbot-primary, #3B82F6);
    color: white;
    border-color: var(--chatbot-primary, #3B82F6);
}

.message-time {
    font-size: 11px;
    color: #94a3b8;
    margin-top: 4px;
    padding: 0 4px;
}

.user-message .message-time {
    text-align: right;
}

/* Typing Indicator */
.chatbot-typing {
    display: flex;
    gap: 8px;
    opacity: 0;
    animation: fadeIn 0.3s ease forwards;
}

.typing-dots {
    background: white;
    padding: 12px 16px;
    border-radius: 18px;
    border: 1px solid #e2e8f0;
    display: flex;
    gap: 4px;
    align-items: center;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    background: #94a3b8;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-8px);
    }
}

/* Input Area */
.chatbot-input-area {
    padding: 16px;
    background: white;
    border-top: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.chatbot-input-wrapper {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    position: relative;
}

.chatbot-input {
    flex: 1;
    border: 1px solid #e2e8f0;
    border-radius: 24px;
    padding: 12px 48px 12px 16px;
    background: #f8fafc;
    outline: none;
    resize: none;
    font-family: inherit;
    font-size: 14px;
    transition: all 0.2s ease;
}

.chatbot-input:focus {
    border-color: var(--chatbot-primary, #3B82F6);
    background: white;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.chatbot-send {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    border: none;
    background: var(--chatbot-primary, #3B82F6);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    opacity: 0.6;
}

.chatbot-send:hover:not(:disabled) {
    opacity: 1;
    transform: translateY(-50%) scale(1.1);
}

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

.chatbot-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
    font-size: 11px;
    color: #94a3b8;
}

.chatbot-status {
    display: flex;
    align-items: center;
    gap: 6px;
}

.status-dot {
    width: 6px;
    height: 6px;
    background: #10b981;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

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

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Dark theme support */
@media (prefers-color-scheme: dark) {
    .chatbot-window {
        background: #1e293b;
    }
    
    .chatbot-messages {
        background: #0f172a;
    }
    
    .message-text {
        background: #334155;
        color: #e2e8f0;
        border-color: #475569;
    }
    
    .typing-dots {
        background: #334155;
        border-color: #475569;
    }
    
    .chatbot-input-area {
        background: #1e293b;
        border-color: #475569;
    }
    
    .chatbot-input {
        background: #0f172a;
        color: #e2e8f0;
        border-color: #475569;
    }
    
    .chatbot-input:focus {
        background: #1e293b;
    }
}

/* Mobile responsive */
@media (max-width: 640px) {
    .chatbot-widget[data-position*="right"] {
        right: 10px;
    }
    
    .chatbot-widget[data-position*="left"] {
        left: 10px;
    }
    
    .chatbot-widget[data-position*="bottom"] {
        bottom: 10px;
    }
    
    .chatbot-window {
        width: calc(100vw - 20px);
        height: 60vh;
        max-height: 500px;
    }
    
    .message-content {
        max-width: calc(100vw - 120px);
    }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    .chatbot-toggle,
    .chatbot-window,
    .chatbot-message,
    .typing-dots span {
        animation: none !important;
        transition: none !important;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .chatbot-window {
        border: 2px solid #000;
    }
    
    .message-text {
        border: 1px solid #000;
    }
    
    .chatbot-input {
        border: 2px solid #000;
    }
}