/* AI Assistant Frontend Chat Widget Styles */

/* Widget Container */
.ai-chat-widget {
    position: fixed;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    --ai-primary-color: #007cba;
    --ai-secondary-color: #ffffff;
    --ai-text-color: #333333;
    --ai-border-color: #e0e0e0;
    --ai-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    --ai-shadow-hover: 0 12px 40px rgba(0, 0, 0, 0.16);
    --ai-border-radius: 16px;
    --ai-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Position Classes */
.ai-chat-widget.bottom-right {
    bottom: 20px;
    right: 20px;
}

.ai-chat-widget.bottom-left {
    bottom: 20px;
    left: 20px;
}

.ai-chat-widget.top-right {
    top: 20px;
    right: 20px;
}

.ai-chat-widget.top-left {
    top: 20px;
    left: 20px;
}

/* Chat Toggle Button */
.chat-toggle {
    width: 60px;
    height: 60px;
    background: var(--ai-primary-color);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--ai-shadow);
    transition: var(--ai-transition);
    position: relative;
    overflow: hidden;
    border: none;
    outline: none;
}

.chat-toggle::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.2) 0%, rgba(255,255,255,0) 100%);
    border-radius: inherit;
    pointer-events: none;
}

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

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

.chat-toggle:focus {
    outline: 2px solid var(--ai-primary-color);
    outline-offset: 4px;
}

.toggle-icon {
    color: white;
    transition: transform 0.3s ease;
    position: relative;
    z-index: 1;
}

.toggle-icon i {
    width: 24px;
    height: 24px;
    stroke-width: 2;
}

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

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

/* Notification Badge */
.notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4444;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    animation: pulse 2s infinite;
    border: 2px solid white;
    box-shadow: 0 2px 8px rgba(255, 68, 68, 0.3);
}

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

/* Chat Window */
.chat-window {
    width: 380px;
    height: 600px;
    background: var(--ai-secondary-color);
    border-radius: var(--ai-border-radius);
    box-shadow: var(--ai-shadow);
    position: absolute;
    bottom: 80px;
    right: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.8) translateY(20px);
    opacity: 0;
    transition: var(--ai-transition);
    border: 1px solid var(--ai-border-color);
}

.chat-window.show {
    transform: scale(1) translateY(0);
    opacity: 1;
}

/* Responsive positioning */
.ai-chat-widget.bottom-left .chat-window,
.ai-chat-widget.top-left .chat-window {
    left: 0;
    right: auto;
}

.ai-chat-widget.top-right .chat-window,
.ai-chat-widget.top-left .chat-window {
    top: 80px;
    bottom: auto;
}

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

.chat-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0) 100%);
    pointer-events: none;
}

.header-content {
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
    z-index: 1;
}

.assistant-avatar {
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
}

.assistant-avatar i {
    width: 20px;
    height: 20px;
    stroke-width: 2;
}

.header-info {
    flex: 1;
}

.assistant-name {
    font-weight: 600;
    font-size: 16px;
    margin-bottom: 2px;
}

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

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4CAF50;
    box-shadow: 0 0 6px rgba(76, 175, 80, 0.5);
    animation: statusPulse 2s ease-in-out infinite;
}

@keyframes statusPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.header-actions {
    display: flex;
    gap: 8px;
    position: relative;
    z-index: 1;
}

.minimize-btn, .close-btn {
    width: 28px;
    height: 28px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
    backdrop-filter: blur(10px);
}

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

.minimize-btn:focus, .close-btn:focus {
    outline: 2px solid rgba(255, 255, 255, 0.5);
    outline-offset: 2px;
}

.minimize-btn i, .close-btn i {
    width: 16px;
    height: 16px;
    stroke-width: 2;
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    scroll-behavior: smooth;
    background: linear-gradient(to bottom, rgba(255,255,255,0.05), transparent 100px);
}

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

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

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

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

.message {
    display: flex;
    margin-bottom: 16px;
    animation: messageSlide 0.4s ease-out;
}

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

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

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

.user-message .message-avatar {
    background: linear-gradient(135deg, #e3f2fd, #bbdefb);
    color: var(--ai-primary-color);
    order: 2;
    margin-right: 0;
    margin-left: 12px;
}

.message-avatar i {
    width: 16px;
    height: 16px;
    stroke-width: 2;
}

.message-content {
    flex: 1;
    max-width: calc(100% - 44px);
}

.user-message .message-content {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.message-text {
    background: #f5f7fa;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    position: relative;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.ai-message .message-text {
    background: linear-gradient(135deg, #f5f7fa, #e8f4f8);
    border-bottom-left-radius: 6px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.user-message .message-text {
    background: var(--ai-primary-color);
    color: white;
    border-bottom-right-radius: 6px;
    box-shadow: 0 1px 3px rgba(0, 124, 186, 0.3);
}

.message-time {
    font-size: 11px;
    color: #999;
    margin-top: 6px;
    padding: 0 4px;
    font-weight: 500;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    margin: 16px 20px;
    opacity: 0;
    animation: fadeIn 0.3s ease-out forwards;
}

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

.typing-animation {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: linear-gradient(135deg, #f5f7fa, #e8f4f8);
    border-radius: 18px;
    border-bottom-left-radius: 6px;
    border: 1px solid rgba(0, 0, 0, 0.05);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

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

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

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

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

/* Quick Actions */
.quick-actions {
    padding: 16px 20px;
    border-top: 1px solid var(--ai-border-color);
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    background: linear-gradient(to bottom, rgba(255,255,255,0.5), rgba(255,255,255,0.8));
}

.quick-action-btn {
    background: white;
    border: 1px solid var(--ai-border-color);
    border-radius: 20px;
    padding: 8px 12px;
    font-size: 12px;
    color: var(--ai-text-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: var(--ai-transition);
    white-space: nowrap;
    font-weight: 500;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.quick-action-btn:hover {
    background: var(--ai-primary-color);
    color: white;
    border-color: var(--ai-primary-color);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 124, 186, 0.3);
}

.quick-action-btn:focus {
    outline: 2px solid var(--ai-primary-color);
    outline-offset: 2px;
}

.quick-action-btn i {
    width: 14px;
    height: 14px;
    stroke-width: 2;
}

/* Lead Collection Form */
.lead-collection-form {
    padding: 20px;
    border-top: 1px solid var(--ai-border-color);
    background: linear-gradient(135deg, #fafbfc, #f5f7fa);
}

.form-header {
    margin-bottom: 16px;
    text-align: center;
}

.form-header h4 {
    margin: 0 0 6px;
    font-size: 18px;
    font-weight: 600;
    color: var(--ai-text-color);
}

.form-header p {
    margin: 0;
    font-size: 14px;
    color: #666;
    line-height: 1.4;
}

.form-group {
    margin-bottom: 14px;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--ai-border-color);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    transition: var(--ai-transition);
    box-sizing: border-box;
    background: white;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--ai-primary-color);
    box-shadow: 0 0 0 3px rgba(0, 124, 186, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
    line-height: 1.5;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}

.submit-btn {
    flex: 1;
    background: var(--ai-primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--ai-transition);
    box-shadow: 0 2px 4px rgba(0, 124, 186, 0.2);
}

.submit-btn:hover {
    background: #005a87;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 124, 186, 0.3);
}

.submit-btn:focus {
    outline: 2px solid var(--ai-primary-color);
    outline-offset: 2px;
}

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

.cancel-btn {
    background: transparent;
    color: #666;
    border: 1px solid var(--ai-border-color);
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 14px;
    cursor: pointer;
    transition: var(--ai-transition);
    font-weight: 500;
}

.cancel-btn:hover {
    background: #f5f5f5;
    border-color: #999;
}

.cancel-btn:focus {
    outline: 2px solid var(--ai-primary-color);
    outline-offset: 2px;
}

/* Chat Input Area */
.chat-input-area {
    border-top: 1px solid var(--ai-border-color);
    padding: 16px 20px;
    background: linear-gradient(to bottom, rgba(255,255,255,0.8), rgba(255,255,255,1));
}

.input-container {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    margin-bottom: 8px;
}

#messageInput {
    flex: 1;
    min-height: 40px;
    max-height: 120px;
    padding: 12px 16px;
    border: 1px solid var(--ai-border-color);
    border-radius: 20px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    transition: var(--ai-transition);
    box-sizing: border-box;
    background: white;
    line-height: 1.4;
}

#messageInput:focus {
    outline: none;
    border-color: var(--ai-primary-color);
    box-shadow: 0 0 0 3px rgba(0, 124, 186, 0.1);
}

#messageInput::placeholder {
    color: #999;
}

.send-btn {
    width: 40px;
    height: 40px;
    background: var(--ai-primary-color);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--ai-transition);
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 124, 186, 0.3);
}

.send-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    box-shadow: none;
}

.send-btn:not(:disabled):hover {
    background: #005a87;
    transform: scale(1.05);
    box-shadow: 0 4px 16px rgba(0, 124, 186, 0.4);
}

.send-btn:focus {
    outline: 2px solid var(--ai-primary-color);
    outline-offset: 2px;
}

.send-btn i {
    width: 18px;
    height: 18px;
    stroke-width: 2;
}

.input-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    color: #999;
}

.character-count {
    font-weight: 500;
}

.powered-by {
    opacity: 0.7;
    font-weight: 500;
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .ai-chat-widget {
        --ai-border-radius: 12px;
    }
    
    .chat-window {
        width: calc(100vw - 40px);
        height: calc(100vh - 120px);
        max-height: 600px;
        border-radius: var(--ai-border-radius);
    }
    
    .ai-chat-widget.bottom-right,
    .ai-chat-widget.bottom-left {
        left: 20px;
        right: 20px;
    }
    
    .ai-chat-widget.bottom-right .chat-window,
    .ai-chat-widget.bottom-left .chat-window {
        left: 0;
        right: 0;
    }
    
    .ai-chat-widget.top-right,
    .ai-chat-widget.top-left {
        left: 20px;
        right: 20px;
    }
    
    .ai-chat-widget.top-right .chat-window,
    .ai-chat-widget.top-left .chat-window {
        left: 0;
        right: 0;
        top: 80px;
    }
    
    .chat-header {
        padding: 14px 16px;
    }
    
    .assistant-name {
        font-size: 15px;
    }
    
    .chat-messages {
        padding: 16px;
    }
    
    .quick-actions {
        padding: 12px 16px;
        justify-content: center;
    }
    
    .quick-action-btn {
        flex: 1;
        justify-content: center;
        min-width: 0;
        padding: 8px 10px;
    }
    
    .lead-collection-form {
        padding: 16px;
    }
    
    .chat-input-area {
        padding: 12px 16px;
    }
    
    .input-container {
        gap: 8px;
    }
    
    #messageInput {
        padding: 10px 14px;
        border-radius: 18px;
    }
    
    .send-btn {
        width: 36px;
        height: 36px;
    }
    
    .send-btn i {
        width: 16px;
        height: 16px;
    }
}

/* Tablet Responsive */
@media (max-width: 768px) and (min-width: 481px) {
    .chat-window {
        width: 360px;
        height: 550px;
    }
    
    .quick-actions {
        flex-wrap: wrap;
    }
    
    .quick-action-btn {
        flex: 1;
        min-width: calc(50% - 4px);
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .ai-chat-widget {
        --ai-text-color: #e0e0e0;
        --ai-border-color: #333;
        --ai-secondary-color: #1a1a1a;
    }
    
    .chat-window {
        background: var(--ai-secondary-color);
        color: var(--ai-text-color);
        border-color: var(--ai-border-color);
    }
    
    .message-text {
        background: #2a2a2a;
        color: var(--ai-text-color);
        border-color: #333;
    }
    
    .ai-message .message-text {
        background: linear-gradient(135deg, #2a2a2a, #333);
    }
    
    .user-message .message-text {
        background: var(--ai-primary-color);
        color: white;
    }
    
    .typing-animation {
        background: linear-gradient(135deg, #2a2a2a, #333);
        border-color: #333;
    }
    
    .quick-actions {
        background: linear-gradient(to bottom, rgba(26,26,26,0.5), rgba(26,26,26,0.8));
        border-color: var(--ai-border-color);
    }
    
    .quick-action-btn {
        background: #2a2a2a;
        border-color: #333;
        color: var(--ai-text-color);
    }
    
    .quick-action-btn:hover {
        background: var(--ai-primary-color);
        color: white;
    }
    
    .lead-collection-form {
        background: linear-gradient(135deg, #1a1a1a, #2a2a2a);
        border-color: var(--ai-border-color);
    }
    
    .form-group input,
    .form-group textarea {
        background: #2a2a2a;
        border-color: #333;
        color: var(--ai-text-color);
    }
    
    .form-group input::placeholder,
    .form-group textarea::placeholder {
        color: #666;
    }
    
    .cancel-btn {
        background: transparent;
        border-color: #333;
        color: #ccc;
    }
    
    .cancel-btn:hover {
        background: #333;
        border-color: #555;
    }
    
    #messageInput {
        background: #2a2a2a;
        color: var(--ai-text-color);
        border-color: #333;
    }
    
    #messageInput::placeholder {
        color: #666;
    }
    
    .chat-input-area {
        background: linear-gradient(to bottom, rgba(26,26,26,0.8), rgba(26,26,26,1));
        border-color: var(--ai-border-color);
    }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .chat-window {
        border: 2px solid var(--ai-text-color);
    }
    
    .message-text {
        border: 1px solid var(--ai-border-color);
    }
    
    .quick-action-btn,
    .form-group input,
    .form-group textarea,
    #messageInput {
        border: 2px solid var(--ai-border-color);
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    .chat-toggle,
    .chat-window,
    .message,
    .typing-indicator,
    .quick-action-btn,
    .send-btn,
    .submit-btn {
        transition: none;
        animation: none;
    }
    
    .notification-badge {
        animation: none;
    }
    
    .status-dot {
        animation: none;
    }
    
    .typing-animation span {
        animation: none;
        opacity: 0.7;
    }
    
    .chat-toggle:hover,
    .send-btn:hover,
    .submit-btn:hover {
        transform: none;
    }
}

/* Print Styles */
@media print {
    .ai-chat-widget {
        display: none !important;
    }
}

/* Widget Entrance Animation */
.ai-chat-widget {
    animation: widgetEntrance 0.6s ease-out;
}

@keyframes widgetEntrance {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Error Message Styles */
.message.error-message .message-text {
    background: linear-gradient(135deg, #ffebee, #ffcdd2);
    color: #c62828;
    border-color: #e57373;
}

/* Loading State for Send Button */
.send-btn.loading {
    pointer-events: none;
}

.send-btn.loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Success States */
.form-success {
    background: linear-gradient(135deg, #e8f5e8, #c8e6c9);
    border: 1px solid #4caf50;
    border-radius: 8px;
    padding: 16px;
    margin: 16px 0;
    color: #2e7d32;
    text-align: center;
    font-weight: 500;
}

/* Focus Trap for Accessibility */
.chat-window[aria-hidden="false"] {
    /* Ensure proper focus management */
}

/* Screen Reader Only Text */
.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}12px 40px rgba(0, 0, 0, 0.16);
    --ai-border-radius: 16px;
    --ai-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Position Classes */
.ai-chat-widget.bottom-right {
    bottom: 20px;
    right: 20px;
}

.ai-chat-widget.bottom-left {
    bottom: 20px;
    left: 20px;
}

.ai-chat-widget.top-right {
    top: 20px;
    right: 20px;
}

.ai-chat-widget.top-left {
    top: 20px;
    left: 20px;
}

/* Chat Toggle Button */
.chat-toggle {
    width: 60px;
    height: 60px;
    background: var(--ai-primary-color);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--ai-shadow);
    transition: var(--ai-transition);
    position: relative;
    overflow: hidden;
    border: none;
    outline: none;
}

.chat-toggle::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.2) 0%, rgba(255,255,255,0) 100%);
    border-radius: inherit;
    pointer-events: none;
}

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

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

.chat-toggle:focus {
    outline: 2px solid var(--ai-primary-color);
    outline-offset: 4px;
}

.toggle-icon {
    color: white;
    transition: transform 0.3s ease;
    position: relative;
    z-index: 1;
}

