/**
 * Enhanced Bot Widget Styles
 * Modern, responsive design with animations
 * Version: 2.0
 */

/* Widget Container */
.bot-widget {
    position: fixed;
    z-index: 10000;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.4;
}

/* Positioning */
.bot-widget--bottom-right {
    bottom: 20px;
    right: 20px;
}

.bot-widget--bottom-left {
    bottom: 20px;
    left: 20px;
}

.bot-widget--top-right {
    top: 20px;
    right: 20px;
}

.bot-widget--top-left {
    top: 20px;
    left: 20px;
}

/* Toggle Button */
.bot-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    position: relative;
    overflow: hidden;
}

.bot-toggle:hover {
    transform: scale(1.05);
    box-shadow: 0 12px 35px rgba(102, 126, 234, 0.6);
}

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

.bot-toggle-icon {
    width: 28px;
    height: 28px;
    color: white;
    transition: transform 0.3s ease;
}

.bot-toggle:hover .bot-toggle-icon {
    transform: rotate(10deg);
}

/* Notification Badge */
.bot-notification {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #ff4757;
    color: white;
    border-radius: 12px;
    padding: 4px 8px;
    font-size: 11px;
    font-weight: 600;
    min-width: 20px;
    text-align: center;
    animation: pulse 2s infinite;
}

.bot-notification--pulse {
    animation: notificationPulse 1.5s infinite;
}

/* Main Container */
.bot-container {
    width: 380px;
    max-width: 90vw;
    height: 600px;
    max-height: 80vh;
    background: white;
    border-radius: 16px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.8) translateY(20px);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.bot-widget--open .bot-container {
    transform: scale(1) translateY(0);
    opacity: 1;
}

/* Header */
.bot-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

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

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

.bot-avatar svg {
    width: 22px;
    height: 22px;
}

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

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

.bot-status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4ade80;
    animation: pulse 2s infinite;
}

.bot-status-indicator--offline {
    background: #f87171;
}

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

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

.bot-minimize:hover,
.bot-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.bot-minimize svg,
.bot-close svg {
    width: 16px;
    height: 16px;
}

/* Messages Area */
.bot-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

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

.bot-messages::-webkit-scrollbar-track {
    background: #f1f5f9;
}

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

.bot-messages::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Message Bubbles */
.bot-message {
    display: flex;
    flex-direction: column;
    animation: messageSlideIn 0.3s ease-out;
}

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

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

.bot-message-content {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 16px;
    word-wrap: break-word;
    position: relative;
}

.bot-message--user .bot-message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.bot-message--bot .bot-message-content {
    background: #f8fafc;
    color: #1e293b;
    border-bottom-left-radius: 4px;
    border: 1px solid #e2e8f0;
}

.bot-message--error .bot-message-content {
    background: #fef2f2;
    color: #dc2626;
    border-color: #fca5a5;
}

.bot-message-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
    font-size: 11px;
    opacity: 0.6;
}

.bot-message--user .bot-message-meta {
    justify-content: flex-end;
}

.bot-message-time {
    font-size: 10px;
}

.bot-message-source {
    font-size: 10px;
    background: #e2e8f0;
    padding: 2px 6px;
    border-radius: 4px;
}

.bot-confidence {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.bot-confidence--high {
    background: #22c55e;
}

.bot-confidence--medium {
    background: #f59e0b;
}

.bot-confidence--low {
    background: #ef4444;
}

/* Quick Actions */
.bot-quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.bot-quick-action {
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
    border: 1px solid rgba(102, 126, 234, 0.3);
    border-radius: 12px;
    padding: 6px 12px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.bot-quick-action:hover {
    background: rgba(102, 126, 234, 0.2);
    transform: translateY(-1px);
}

/* Message Actions */
.bot-message-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.bot-message:hover .bot-message-actions {
    opacity: 1;
}

.bot-message-actions--disabled {
    opacity: 0.5;
    pointer-events: none;
}

.bot-feedback-btn {
    width: 28px;
    height: 28px;
    border: none;
    background: #f1f5f9;
    color: #64748b;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.bot-feedback-btn:hover {
    background: #e2e8f0;
    transform: scale(1.1);
}

.bot-feedback-btn--selected {
    background: #22c55e;
    color: white;
}

.bot-feedback-btn svg {
    width: 14px;
    height: 14px;
}

/* Suggested Actions */
.bot-suggested-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.bot-action-btn {
    background: #f8fafc;
    color: #475569;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 12px;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    transition: all 0.2s ease;
}

.bot-action-btn:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
    transform: translateY(-1px);
}

.bot-action-btn--primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: transparent;
}

.bot-action-btn--primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.bot-action-btn--link {
    color: #667eea;
}

/* Typing Indicator */
.bot-typing-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    color: #64748b;
    font-size: 12px;
    animation: fadeIn 0.3s ease;
}

.bot-typing-dots {
    display: flex;
    gap: 4px;
}

.bot-typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #cbd5e1;
    animation: typingDot 1.4s infinite ease-in-out;
}

.bot-typing-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.bot-typing-dot:nth-child(2) {
    animation-delay: -0.16s;
}

/* Input Container */
.bot-input-container {
    border-top: 1px solid #e2e8f0;
    background: white;
}

.bot-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    padding: 16px 20px;
}

.bot-input {
    flex: 1;
    border: none;
    outline: none;
    resize: none;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.4;
    min-height: 20px;
    max-height: 100px;
    padding: 0;
    background: transparent;
}

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

.bot-send {
    width: 36px;
    height: 36px;
    border: none;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.bot-send:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

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

.bot-send svg {
    width: 18px;
    height: 18px;
}

.bot-footer {
    padding: 8px 20px 12px;
    text-align: center;
}

.bot-powered {
    font-size: 10px;
    color: #94a3b8;
}

.bot-powered a {
    color: #667eea;
    text-decoration: none;
}

/* Ticket Form */
.bot-ticket-form {
    background: #f8fafc;
    border-radius: 8px;
    padding: 16px;
    border: 1px solid #e2e8f0;
}

.bot-ticket-form h3 {
    margin: 0 0 16px 0;
    color: #1e293b;
    font-size: 16px;
}

.bot-form-group {
    margin-bottom: 12px;
}

.bot-form-group label {
    display: block;
    margin-bottom: 4px;
    font-size: 12px;
    color: #475569;
    font-weight: 500;
}

.bot-form-group input,
.bot-form-group select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s ease;
}

.bot-form-group input:focus,
.bot-form-group select:focus {
    border-color: #667eea;
}

.bot-form-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 16px;
}

.bot-form-btn {
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
}

.bot-form-btn--cancel {
    background: #f1f5f9;
    color: #64748b;
}

.bot-form-btn--cancel:hover {
    background: #e2e8f0;
}

.bot-form-btn--submit {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.bot-form-btn--submit:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.bot-form-btn--submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Success Message */
.bot-success-message {
    text-align: center;
    padding: 20px;
}

.bot-success-message h3 {
    color: #22c55e;
    margin: 0 0 12px 0;
}

.bot-ticket-link {
    display: inline-block;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 6px;
    margin-top: 12px;
    transition: transform 0.2s ease;
}

.bot-ticket-link:hover {
    transform: translateY(-1px);
}

/* Dark Theme */
.bot-widget--dark .bot-container {
    background: #1e293b;
    color: #e2e8f0;
}

.bot-widget--dark .bot-messages::-webkit-scrollbar-track {
    background: #334155;
}

.bot-widget--dark .bot-messages::-webkit-scrollbar-thumb {
    background: #64748b;
}

.bot-widget--dark .bot-message--bot .bot-message-content {
    background: #334155;
    color: #e2e8f0;
    border-color: #475569;
}

.bot-widget--dark .bot-input-container {
    border-color: #475569;
    background: #1e293b;
}

.bot-widget--dark .bot-input::placeholder {
    color: #64748b;
}

.bot-widget--dark .bot-ticket-form {
    background: #334155;
    border-color: #475569;
}

.bot-widget--dark .bot-form-group input,
.bot-widget--dark .bot-form-group select {
    background: #1e293b;
    border-color: #475569;
    color: #e2e8f0;
}

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

@keyframes notificationPulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
    }
}

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

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

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

/* Mobile Responsive */
@media (max-width: 480px) {
    .bot-widget {
        bottom: 10px !important;
        right: 10px !important;
        left: 10px !important;
    }
    
    .bot-container {
        width: 100%;
        height: 70vh;
        border-radius: 12px;
    }
    
    .bot-toggle {
        width: 56px;
        height: 56px;
    }
    
    .bot-toggle-icon {
        width: 24px;
        height: 24px;
    }
    
    .bot-messages {
        padding: 16px;
    }
    
    .bot-input-wrapper {
        padding: 12px 16px;
    }
    
    .bot-header {
        padding: 12px 16px;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .bot-toggle {
        border: 2px solid #000;
    }
    
    .bot-message--bot .bot-message-content {
        border-width: 2px;
    }
    
    .bot-form-group input,
    .bot-form-group select {
        border-width: 2px;
    }
}

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