/* Chatbot Frontend Widget Styles */
:root {
    --chatbot-primary: #3B82F6;
    --chatbot-secondary: #64748B;
    --chatbot-background: #ffffff;
    --chatbot-text: #1e293b;
    --chatbot-border: #e2e8f0;
    --chatbot-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    --chatbot-radius: 12px;
    --chatbot-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.chatbot-widget {
    position: fixed;
    z-index: 9999;
    font-family: var(--chatbot-font);
    font-size: 14px;
    line-height: 1.5;
}

/* 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: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--chatbot-primary);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--chatbot-shadow);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.chatbot-toggle:hover {
    transform: scale(1.05);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.15);
}

.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 {
    transform: rotate(180deg);
    opacity: 0;
}

.chatbot-toggle.active .close-icon {
    display: block !important;
    transform: rotate(0deg);
    opacity: 1;
}

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

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* Chat Window */
.chatbot-window {
    width: 350px;
    height: 500px;
    background: var(--chatbot-background);
    border-radius: var(--chatbot-radius);
    box-shadow: var(--chatbot-shadow);
    display: flex;
    flex-direction: column;
    position: absolute;
    bottom: 80px;
    right: 0;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all 0.3s ease;
}

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

.chatbot-widget[data-position="bottom-left"] .chatbot-window,
.chatbot-widget[data-position="top-left"] .chatbot-window {
    right: auto;
    left: 0;
}

.chatbot-widget[data-position="top-right"] .chatbot-window,
.chatbot-widget[data-position="top-left"] .chatbot-window {
    bottom: auto;
    top: 80px;
}

/* Header */
.chatbot-header {
    padding: 20px;
    background: var(--chatbot-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

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

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

.chatbot-info {
    display: flex;
    flex-direction: column;
}

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

.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.2);
    border-radius: 4px;
    color: white;
    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.3);
}

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

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

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

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

.chatbot-message {
    display: flex;
    gap: 10px;
    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;
}

.bot-message .message-avatar {
    background: var(--chatbot-primary);
    color: white;
}

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

.message-content {
    max-width: 70%;
    display: flex;
    flex-direction: column;
}

.message-text {
    background: white;
    padding: 12px 16px;
    border-radius: 18px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    color: var(--chatbot-text);
    word-wrap: break-word;
    position: relative;
}

.user-message .message-text {
    background: var(--chatbot-primary);
    color: white;
}

.message-time {
    font-size: 11px;
    color: #64748b;
    margin-top: 4px;
    text-align: left;
}

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

/* Typing Indicator */
.chatbot-typing {
    display: flex;
    gap: 10px;
    padding: 0 20px;
    animation: fadeInUp 0.3s ease;
}

.typing-dots {
    background: white;
    padding: 12px 16px;
    border-radius: 18px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    display: flex;
    gap: 4px;
    align-items: center;
}

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

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

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

/* Input Area */
.chatbot-input-area {
    border-top: 1px solid var(--chatbot-border);
    background: white;
}

.chatbot-input-wrapper {
    padding: 20px;
    display: flex;
    gap: 12px;
    align-items: center;
}

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

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

.chatbot-input::placeholder {
    color: #94a3b8;
}

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

.chatbot-send:hover {
    background: #2563eb;
    transform: scale(1.05);
}

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

.chatbot-send:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Footer */
.chatbot-footer {
    padding: 12px 20px;
    background: #f8fafc;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    color: #64748b;
    border-top: 1px solid var(--chatbot-border);
}

.chatbot-powered {
    font-weight: 500;
}

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

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

/* Error States */
.chatbot-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
    padding: 12px 16px;
    border-radius: 8px;
    margin: 10px 20px;
    font-size: 13px;
}

.chatbot-offline {
    background: #fefce8;
    border: 1px solid #fde047;
    color: #a16207;
    padding: 12px 16px;
    border-radius: 8px;
    margin: 10px 20px;
    font-size: 13px;
}

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

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
    .chatbot-window {
        width: calc(100vw - 40px);
        height: calc(100vh - 100px);
        bottom: 80px;
        right: 20px;
        left: 20px;
    }
    
    .chatbot-widget[data-position="bottom-left"] .chatbot-window {
        left: 20px;
        right: 20px;
    }
    
    .chatbot-widget[data-position="top-right"] .chatbot-window,
    .chatbot-widget[data-position="top-left"] .chatbot-window {
        top: 80px;
        left: 20px;
        right: 20px;
    }
    
    .chatbot-header {
        padding: 16px;
    }
    
    .chatbot-messages {
        padding: 16px;
    }
    
    .chatbot-input-wrapper {
        padding: 16px;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    :root {
        --chatbot-background: #1e293b;
        --chatbot-text: #f1f5f9;
        --chatbot-border: #334155;
    }
    
    .chatbot-window {
        background: var(--chatbot-background);
        color: var(--chatbot-text);
    }
    
    .chatbot-messages {
        background: #0f172a;
    }
    
    .message-text {
        background: #334155;
        color: var(--chatbot-text);
    }
    
    .user-message .message-text {
        background: var(--chatbot-primary);
        color: white;
    }
    
    .chatbot-input {
        background: #334155;
        border-color: #475569;
        color: var(--chatbot-text);
    }
    
    .chatbot-input::placeholder {
        color: #64748b;
    }
    
    .chatbot-footer {
        background: #0f172a;
        border-color: #334155;
    }
    
    .typing-dots {
        background: #334155;
    }
}

/* Accessibility */
.chatbot-toggle:focus,
.chatbot-send:focus,
.chatbot-input:focus,
.chatbot-minimize:focus,
.chatbot-close:focus {
    outline: 2px solid var(--chatbot-primary);
    outline-offset: 2px;
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .chatbot-toggle {
        border: 2px solid white;
    }
    
    .message-text {
        border: 1px solid var(--chatbot-text);
    }
    
    .chatbot-input {
        border: 2px solid var(--chatbot-text);
    }
}

/* Loading States */
.chatbot-loading {
    opacity: 0.7;
    pointer-events: none;
}

.chatbot-loading .chatbot-send {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Connection Status */
.chatbot-connection-status {
    padding: 8px 20px;
    background: #fef3c7;
    border-bottom: 1px solid #fbbf24;
    color: #92400e;
    font-size: 12px;
    text-align: center;
}

.chatbot-connection-status.connected {
    background: #d1fae5;
    border-color: #10b981;
    color: #065f46;
}

.chatbot-connection-status.error {
    background: #fee2e2;
    border-color: #ef4444;
    color: #991b1b;
}
