/* Smart Product Chat Widget Styles */

#smart-chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* Chat Button */
#chat-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

#chat-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

#chat-button svg {
    width: 28px;
    height: 28px;
}

/* Chat Window */
#chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    height: 550px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Chat Header */
#chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
}

#chat-close {
    background: transparent;
    border: none;
    color: white;
    font-size: 28px;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s;
}

#chat-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Messages Area */
#chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

#chat-messages::-webkit-scrollbar {
    width: 6px;
}

#chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

#chat-messages::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 3px;
}

/* Message Bubbles */
.chat-message {
    padding: 12px 16px;
    border-radius: 16px;
    max-width: 80%;
    word-wrap: break-word;
    line-height: 1.5;
    font-size: 14px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-message.bot {
    background: white;
    color: #2d3748;
    align-self: flex-start;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.chat-message.user {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    align-self: flex-end;
    margin-left: auto;
}

.chat-message.typing {
    background: white;
    color: #718096;
    font-style: italic;
    border: 1px solid #e2e8f0;
}

.chat-message a {
    color: #667eea;
    text-decoration: underline;
}

.chat-message.user a {
    color: white;
    font-weight: 600;
}

/* Input Area */
#chat-input-area {
    padding: 16px;
    background: white;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 10px;
}

#chat-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #e2e8f0;
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

#chat-input:focus {
    border-color: #667eea;
}

#chat-send {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
}

#chat-send:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

#chat-send:active {
    transform: scale(0.95);
}

#chat-send svg {
    width: 20px;
    height: 20px;
}

/* Mobile Responsive */

/* Tablets and small laptops */
@media (max-width: 768px) {
    #chat-window {
        width: 90vw !important;
        max-width: 400px !important;
        height: 500px !important;
        right: 5% !important;
        left: auto !important;
    }
}

/* Mobile devices - landscape */
@media (max-width: 640px) and (orientation: landscape) {
    #chat-window {
        width: calc(100vw - 20px) !important;
        height: calc(100vh - 80px) !important;
        bottom: 70px !important;
        right: auto !important;
        left: 10px !important;
        max-height: 400px !important;
    }

    #smart-chat-widget {
        right: 10px !important;
        bottom: 10px !important;
    }

    #chat-button {
        width: 50px !important;
        height: 50px !important;
    }

    #chat-button svg {
        width: 24px !important;
        height: 24px !important;
    }
}

/* Mobile devices - portrait */
@media (max-width: 480px) {
    #chat-window {
        width: 100vw !important;
        height: 100vh !important;
        bottom: 0 !important;
        right: auto !important;
        left: 0 !important;
        border-radius: 0 !important;
        max-height: none !important;
    }

    #smart-chat-widget {
        right: 15px;
        bottom: 15px;
    }

    #chat-button {
        width: 56px;
        height: 56px;
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    }

    #chat-button svg {
        width: 26px;
        height: 26px;
    }

    #chat-header {
        padding: 14px 16px;
        font-size: 16px;
    }

    #chat-messages {
        padding: 12px;
        gap: 10px;
    }

    .chat-message {
        max-width: 85%;
        font-size: 15px;
        padding: 10px 14px;
    }

    #chat-input-area {
        padding: 12px;
        gap: 8px;
    }

    #chat-input {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 10px 14px;
    }

    #chat-send {
        width: 42px;
        height: 42px;
        flex-shrink: 0;
    }

    #chat-send svg {
        width: 18px;
        height: 18px;
    }
}

/* Very small mobile devices */
@media (max-width: 360px) {
    #chat-button {
        width: 52px;
        height: 52px;
    }

    #smart-chat-widget {
        right: 12px;
        bottom: 12px;
    }

    .chat-message {
        font-size: 14px;
        padding: 9px 12px;
    }

    #chat-input {
        font-size: 16px;
        padding: 9px 12px;
    }
}

/* Fix for mobile Safari */
@supports (-webkit-touch-callout: none) {
    #chat-window {
        height: -webkit-fill-available;
    }
}

/* Prevent text selection on double-tap (mobile) */
#chat-button,
#chat-send,
#chat-close {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

/* Loading Animation */
.chat-message.typing::after {
    content: '...';
    animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
    0%, 20% {
        content: '.';
    }
    40% {
        content: '..';
    }
    60%, 100% {
        content: '...';
    }
}
