/* Sage AI Assistant Chat Interface Styles */

/* Floating Chat Button */
.sage-chat-button {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #80BC5C 0%, #0B4F1F 100%);
    border: none;
    box-shadow: 0 4px 12px rgba(11, 79, 31, 0.3);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 1000;
}

.sage-chat-button:hover {
    transform: translateX(-50%) scale(1.1);
    box-shadow: 0 6px 20px rgba(11, 79, 31, 0.4);
}

.sage-chat-button svg {
    width: 30px;
    height: 30px;
    fill: white;
}

.sage-chat-button.active {
    background: #0B4F1F;
}

/* Chat Modal Container */
.sage-chat-modal {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    width: 400px;
    max-height: 600px;
    background: #FFFCEF;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    display: none;
    flex-direction: column;
    z-index: 1001;
    overflow: hidden;
}

.sage-chat-modal.active {
    display: flex;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Chat Header */
.sage-chat-header {
    background: linear-gradient(135deg, #80BC5C 0%, #0B4F1F 100%);
    color: white;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sage-chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sage-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #0B4F1F;
    font-size: 1.2rem;
}

.sage-name-status h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.sage-status {
    font-size: 0.85rem;
    opacity: 0.9;
}

.sage-close-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 1.5rem;
    padding: 5px;
    line-height: 1;
}

.sage-close-btn:hover {
    opacity: 0.8;
}

/* Chat Messages Area */
.sage-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-height: 300px;
    max-height: 400px;
}

.sage-message {
    display: flex;
    gap: 10px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.sage-message.user {
    flex-direction: row-reverse;
}

.sage-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
}

.sage-message.assistant .sage-message-avatar {
    background: #80BC5C;
    color: white;
}

.sage-message.user .sage-message-avatar {
    background: #0B4F1F;
    color: white;
}

.sage-message-bubble {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 0.95rem;
    line-height: 1.5;
}

.sage-message.assistant .sage-message-bubble {
    background: #e0e9cd;
    color: #0B4F1F;
    border-bottom-left-radius: 4px;
}

.sage-message.user .sage-message-bubble {
    background: #0B4F1F;
    color: white;
    border-bottom-right-radius: 4px;
}

/* Product Recommendations */
.sage-products {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 12px;
    width: 100%;
}

.sage-product-card {
    background: white;
    border: 1px solid #e0e9cd;
    border-radius: 12px;
    padding: 12px;
    display: flex;
    gap: 12px;
    transition: all 0.2s ease;
    min-height: 90px;
    width: 100%;
}

.sage-product-card:hover {
    border-color: #80BC5C;
    box-shadow: 0 2px 8px rgba(128, 188, 92, 0.1);
}

.sage-product-image {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 8px;
    flex-shrink: 0;
}

.sage-product-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sage-product-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: #0B4F1F;
    margin: 0;
    line-height: 1.4;
    word-break: break-word;
    overflow-wrap: anywhere;
    hyphens: auto;
}

.sage-product-vendor {
    font-size: 0.8rem;
    color: #666;
    margin: 0;
}

.sage-product-price {
    font-weight: 600;
    color: #0B4F1F;
    font-size: 0.95rem;
    margin: 0;
}

.sage-product-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: auto;
}

.sage-add-to-cart-btn {
    background: #80BC5C;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.sage-add-to-cart-btn:hover {
    background: #0B4F1F;
}

.sage-add-to-cart-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.sage-product-quantity {
    font-size: 0.85rem;
    color: #666;
    margin: 0;
}

/* Typing Indicator */
.sage-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    background: #e0e9cd;
    border-radius: 16px;
    width: fit-content;
}

.sage-typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #0B4F1F;
    animation: typing 1.4s infinite;
}

.sage-typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.sage-typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Chat Input */
.sage-chat-input-container {
    padding: 16px;
    background: white;
    border-top: 1px solid #e0e9cd;
}

.sage-chat-input-wrapper {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.sage-chat-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e0e9cd;
    border-radius: 24px;
    font-size: 0.95rem;
    font-family: 'Lato', sans-serif;
    resize: none;
    max-height: 120px;
    transition: border-color 0.2s ease;
}

.sage-chat-input:focus {
    outline: none;
    border-color: #80BC5C;
}

.sage-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #80BC5C;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.sage-send-btn:hover {
    background: #0B4F1F;
    transform: scale(1.05);
}

.sage-send-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: scale(1);
}

.sage-send-btn svg {
    width: 20px;
    height: 20px;
    fill: white;
}

/* Welcome Message */
.sage-welcome {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}

.sage-welcome-icon {
    width: 60px;
    height: 60px;
    margin: 0 auto 16px;
    background: linear-gradient(135deg, #80BC5C 0%, #0B4F1F 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sage-welcome-icon svg {
    width: 30px;
    height: 30px;
    fill: white;
}

.sage-welcome h4 {
    font-size: 1.1rem;
    color: #0B4F1F;
    margin: 0 0 8px 0;
}

.sage-welcome p {
    font-size: 0.9rem;
    margin: 0;
    line-height: 1.5;
}

/* Suggestion Chips */
.sage-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
    padding: 0 20px;
}

.sage-suggestion-chip {
    background: white;
    border: 1px solid #e0e9cd;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
    color: #0B4F1F;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sage-suggestion-chip:hover {
    background: #80BC5C;
    color: white;
    border-color: #80BC5C;
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .sage-chat-modal {
        width: calc(100% - 20px);
        left: 50%;
        transform: translateX(-50%);
        bottom: 90px;
        max-height: 70vh; /* Reduced from 500px to 70vh */
    }

    .sage-chat-messages {
        max-height: calc(70vh - 180px); /* Leave room for header and input */
        min-height: 200px; /* Reduced from 300px */
    }

    .sage-chat-header {
        padding: 16px; /* Slightly smaller padding */
    }

    .sage-chat-input-container {
        padding: 12px; /* Smaller padding */
    }

    .sage-chat-input-wrapper {
        gap: 8px; /* Reduce gap */
    }

    .sage-chat-input {
        padding: 10px 14px; /* Slightly smaller padding */
        font-size: 0.9rem;
        max-height: 100px; /* Reduced from 120px */
    }

    .sage-send-btn {
        width: 40px;
        height: 40px;
        flex-shrink: 0; /* Prevent button from shrinking */
    }

    .sage-chat-button {
        bottom: 20px;
        left: 50%;
        transform: translateX(-50%);
        width: 56px; /* Slightly smaller */
        height: 56px;
    }

    .sage-chat-button:hover {
        transform: translateX(-50%) scale(1.1);
    }

    .sage-chat-button svg {
        width: 28px;
        height: 28px;
    }

    /* Product cards on mobile */
    .sage-product-card {
        padding: 10px;
        min-height: 80px; /* Smaller on mobile */
    }

    .sage-product-image {
        width: 50px;
        height: 50px;
    }

    .sage-product-name {
        font-size: 0.85rem;
        line-height: 1.3;
        /* Allow wrapping */
        white-space: normal !important;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    .sage-product-vendor {
        font-size: 0.75rem;
    }

    .sage-product-price {
        font-size: 0.85rem;
    }

    .sage-add-to-cart-btn {
        padding: 6px 12px;
        font-size: 0.8rem;
    }

    /* Message bubbles */
    .sage-message-bubble {
        max-width: 85%; /* Use more width on mobile */
        padding: 10px 14px;
        font-size: 0.9rem;
    }

    /* Welcome message */
    .sage-welcome {
        padding: 30px 16px;
    }

    .sage-welcome h4 {
        font-size: 1rem;
    }

    .sage-welcome p {
        font-size: 0.85rem;
    }

    /* Suggestion chips */
    .sage-suggestions {
        padding: 0 16px;
    }

    .sage-suggestion-chip {
        padding: 6px 12px;
        font-size: 0.8rem;
    }
}

/* Additional breakpoint for very small screens */
@media (max-width: 375px) {
    .sage-chat-modal {
        max-height: 65vh; /* Even smaller for tiny screens */
        width: calc(100% - 16px);
    }

    .sage-chat-messages {
        max-height: calc(65vh - 170px);
        min-height: 180px;
    }

    .sage-product-card {
        flex-direction: column; /* Stack vertically on very small screens */
        align-items: center;
        text-align: center;
    }

    .sage-product-info {
        width: 100%;
    }
}

/* Scrollbar Styling */
.sage-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.sage-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.sage-chat-messages::-webkit-scrollbar-thumb {
    background: #e0e9cd;
    border-radius: 3px;
}

.sage-chat-messages::-webkit-scrollbar-thumb:hover {
    background: #80BC5C;
}