/* AI Chat Widget Styles - Monochrome Theme */
@import url('theme.css');

.ai-chat-widget {
    position: fixed;
    bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    right: calc(20px + env(safe-area-inset-right, 0px));
    width: 380px;
    max-width: calc(100vw - 40px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px));
    max-height: min(600px, calc(100dvh - 40px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)));
    background: var(--card-bg);
    border-radius: 16px;
    box-shadow: var(--shadow-xl);
    display: flex;
    flex-direction: column;
    z-index: 3000;
    transition: all 0.3s ease;
    /* Keep clear of the left edge used by iOS swipe-back */
    touch-action: manipulation;
}

.ai-chat-widget.minimized {
    width: 60px;
    height: 60px;
    max-height: 60px;
    border-radius: 50%;
    cursor: pointer;
}

.ai-chat-widget.minimized .chat-header {
    height: 60px;
    border-radius: 50%;
    justify-content: center;
    cursor: pointer;
}

.ai-chat-widget.minimized .chat-header-text {
    display: none;
}

.ai-chat-widget.minimized .chat-messages,
.ai-chat-widget.minimized .chat-input-container,
.ai-chat-widget.minimized .chat-suggestions {
    display: none;
}

/* Chat Header */
.chat-header {
    padding: 16px 20px;
    background: linear-gradient(135deg, var(--grey-600) 0%, var(--grey-700) 100%);
    border-radius: 16px 16px 0 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--grey-50);
    gap: 12px;
}

.chat-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

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

.chat-header-text h3 {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}

.chat-header-text p {
    font-size: 12px;
    margin: 0;
    opacity: 0.9;
}

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

.status-dot {
    width: 8px;
    height: 8px;
    background: var(--grey-300);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

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

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

.chat-header-btn {
    width: 32px;
    height: 32px;
    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.3s;
}

.chat-header-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: var(--bg-dark);
}

.chat-message {
    display: flex;
    gap: 10px;
    animation: messageSlideIn 0.3s ease;
}

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

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

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

.message-avatar.bot {
    background: linear-gradient(135deg, var(--grey-500), var(--grey-400));
}

.message-avatar.user {
    background: var(--grey-600);
}

.message-content {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.chat-message.bot .message-content {
    background: var(--card-bg);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}

.chat-message.user .message-content {
    background: var(--grey-600);
    color: var(--grey-50);
    border-bottom-right-radius: 4px;
}

.message-time {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: var(--card-bg);
    border-radius: 12px;
    width: fit-content;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: typingBounce 1.4s infinite;
}

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

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

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

/* Chat Suggestions */
.chat-suggestions {
    padding: 12px 20px;
    background: var(--bg-dark);
    border-top: 1px solid var(--border-light);
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.suggestion-chip {
    padding: 8px 14px;
    background: var(--card-bg);
    border: 1px solid var(--border-light);
    border-radius: 20px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s;
}

.suggestion-chip:hover {
    background: var(--grey-600);
    border-color: var(--grey-500);
    color: var(--grey-200);
}

/* Chat Input */
.chat-input-container {
    padding: 16px 20px;
    background: var(--card-bg);
    border-top: 1px solid var(--border-light);
    border-radius: 0 0 16px 16px;
}

.chat-input-wrapper {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.chat-input {
    flex: 1;
    padding: 12px 16px;
    background: var(--bg-dark);
    border: 2px solid var(--border-light);
    border-radius: 24px;
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    resize: none;
    max-height: 100px;
    transition: border-color 0.3s;
}

.chat-input:focus {
    outline: none;
    border-color: var(--focus-ring);
}

.chat-input::placeholder {
    color: var(--text-muted);
}

.chat-send-btn {
    width: 44px;
    height: 44px;
    background: var(--grey-500);
    border: none;
    border-radius: 50%;
    color: var(--grey-50);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    flex-shrink: 0;
}

.chat-send-btn:hover:not(:disabled) {
    background: var(--grey-400);
    transform: scale(1.05);
}

.chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Welcome Message */
.chat-welcome {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

.chat-welcome-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.chat-welcome h4 {
    font-size: 18px;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.chat-welcome p {
    font-size: 14px;
    line-height: 1.6;
}

/* Product Cards in Chat */
.chat-product-card {
    background: var(--bg-dark);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 12px;
    margin-top: 8px;
    cursor: pointer;
    transition: all 0.3s;
}

.chat-product-card:hover {
    border-color: var(--grey-500);
    background: var(--grey-700);
}

.chat-product-card h5 {
    font-size: 14px;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.chat-product-card p {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.chat-product-price {
    font-size: 16px;
    font-weight: 700;
    color: var(--grey-300);
}

/* Mobile Responsiveness */
@media (max-width: 640px) {
    .ai-chat-widget {
        bottom: 10px;
        right: 10px;
        left: 10px;
        width: auto;
        max-width: none;
        max-height: 80vh;
    }

    .ai-chat-widget.minimized {
        left: auto;
        width: 60px;
    }

    .chat-messages {
        padding: 16px;
    }

    .message-content {
        max-width: 85%;
    }
}

/* Scrollbar Styling */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

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

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--grey-500);
}

/* Notification Badge */
.chat-notification {
    position: absolute;
    top: -6px;
    right: -6px;
    background: var(--grey-500);
    color: var(--grey-50);
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    animation: notificationPulse 2s infinite;
}

@keyframes notificationPulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(108, 117, 125, 0.7);
    }
    50% {
        transform: scale(1.1);
        box-shadow: 0 0 0 6px rgba(108, 117, 125, 0);
    }
}

/* Loading State */
.chat-loading {
    text-align: center;
    padding: 20px;
    color: var(--text-muted);
}

.chat-loading-spinner {
    display: inline-block;
    width: 30px;
    height: 30px;
    border: 3px solid var(--border-light);
    border-top-color: var(--grey-400);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Error State */
.chat-error {
    padding: 12px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 8px;
    color: var(--error);
    font-size: 13px;
    text-align: center;
}

/* Powered By */
.chat-powered-by {
    text-align: center;
    padding: 8px;
    font-size: 11px;
    color: var(--text-muted);
    border-top: 1px solid var(--border-light);
}

.chat-powered-by a {
    color: var(--grey-400);
    text-decoration: none;
}

.chat-powered-by a:hover {
    text-decoration: underline;
}
