/**
 * ConvertyBot Chatbot - Frontend Styles
 */

/* Chat Widget Container */
.convertybot-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

/* Chat Button */
.convertybot-chat-button {
    background: var(--convertybot-primary, #007cba);
    color: white;
    border-radius: 50px;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
    border: none;
    font-size: 14px;
    font-weight: 500;
}

.convertybot-chat-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.convertybot-chat-button svg {
    width: 24px;
    height: 24px;
}

.convertybot-badge {
    background: #ff4444;
    color: white;
    border-radius: 10px;
    padding: 2px 6px;
    font-size: 11px;
    font-weight: bold;
    min-width: 18px;
    text-align: center;
}

/* Chat Window */
.convertybot-chat-window {
    position: absolute;
    bottom: 10px;
    right: 0;
    width: 380px;
    height: 500px;
    background: var(--convertybot-bg, white);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    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 */
.convertybot-chat-header {
    background: var(--convertybot-primary, #007cba);
    color: white;
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

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

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

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

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

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

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

.convertybot-header-actions button {
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    padding: 4px;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.convertybot-header-actions button:hover {
    opacity: 1;
}

/* Messages Container */
.convertybot-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: var(--convertybot-bg, #f9f9f9);
}

.convertybot-message {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    animation: fadeIn 0.3s ease;
}

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

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

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--convertybot-primary, #007cba);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
}

.convertybot-message.user .message-avatar {
    background: #6c757d;
}

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

.message-bubble {
    background: white;
    padding: 10px 14px;
    border-radius: 16px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    word-wrap: break-word;
}

.convertybot-message.user .message-bubble {
    background: var(--convertybot-primary, #007cba);
    color: white;
}

/* Suggestions */
.message-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.suggestion-chip {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 16px;
    padding: 6px 12px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.suggestion-chip:hover {
    background: var(--convertybot-primary, #007cba);
    color: white;
    border-color: var(--convertybot-primary, #007cba);
}

/* Typing Indicator */
/* ✅ FIX Bug 4: Ensure typing area has white background */
.convertybot-typing {
    padding: 12px 16px;
    background: #ffffff;
}

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

.typing-indicator span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #999;
    animation: typing 1.4s infinite;
}

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

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

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

/* Product Carousel */
.convertybot-products {
    padding: 12px;
    background: white;
    border-top: 1px solid #e0e0e0;
}

.products-carousel {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 8px;
}

.product-card {
    min-width: 140px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.product-card:hover {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.product-card img {
    width: 100%;
    height: 100px;
    object-fit: cover;
    border-radius: 4px;
}

.product-card h5 {
    margin: 8px 0 4px;
    font-size: 13px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.product-card .price {
    color: var(--convertybot-primary, #007cba);
    font-weight: bold;
    font-size: 14px;
}

/* Input Area */
.convertybot-chat-input {
    padding: 12px;
    background: white;
    border-top: 1px solid #e0e0e0;
}

.convertybot-chat-input form {
    display: flex;
    gap: 8px;
}

.convertybot-chat-input input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #e0e0e0;
    border-radius: 24px;
    outline: none;
    font-size: 14px;
}

.convertybot-chat-input input:focus {
    border-color: var(--convertybot-primary, #007cba);
}

.convertybot-chat-input button {
    background: var(--convertybot-primary, #007cba);
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.convertybot-chat-input button:hover {
    background: #005a8a;
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .convertybot-chat-window {
        width: 100%;
        height: 100%;
        bottom: 0;
        right: 0;
        border-radius: 0;
        position: fixed;
    }
    
    .convertybot-chat-button {
        bottom: 10px;
        right: 10px;
    }
}

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

.convertybot-chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.convertybot-chat-messages::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

.convertybot-chat-messages::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Inline Product Cards within Message Bubbles */
.ai-products-inline {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 15px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
}

.ai-product-card-inline {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 12px;
    transition: all 0.3s ease;
}

.ai-product-card-inline:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    border-color: var(--convertybot-primary, #007cba);
}

.product-inline-content {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.product-inline-image {
    /* width: 80px; */
    height: 40px;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
    background: #f5f5f5;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: 12px;
}

.product-inline-image.no-image {
    border: 2px dashed #ddd;
}

.product-inline-details {
    flex: 1;
}

.product-inline-details h5 {
    margin: 0 0 6px 0;
    font-size: 14px;
    font-weight: 600;
    color: #333;
    line-height: 1.3;
}

.product-inline-rating {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
}

.product-inline-rating .stars {
    color: #ffc107;
    font-size: 14px;
    letter-spacing: 1px;
}

.product-inline-rating .reviews {
    font-size: 12px;
    color: #666;
}

.product-inline-description {
    margin: 0 0 8px 0;
    font-size: 13px;
    color: #666;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.product-inline-price {
    font-size: 16px;
    font-weight: bold;
    color: var(--convertybot-primary, #007cba);
    margin-bottom: 8px;
}

.product-inline-link {
    display: inline-block;
    padding: 6px 12px;
    background: var(--convertybot-primary, #007cba);
    color: white !important;
    text-decoration: none;
    border-radius: 4px;
    font-size: 13px;
    transition: all 0.3s ease;
}

.product-inline-link:hover {
    background: #005a8a;
    text-decoration: none;
    color: white !important;
}

.product-inline-link.clicked {
    opacity: 0.7;
    pointer-events: none;
}

/* More Products Button */
.ai-more-products-section {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #e0e0e0;
    text-align: center;
}

.ai-more-products-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: linear-gradient(135deg, var(--convertybot-primary, #007cba) 0%, #005a8a 100%);
    color: white;
    border: none;
    border-radius: 25px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 10px rgba(0, 124, 186, 0.3);
}

.ai-more-products-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 124, 186, 0.4);
}

.ai-more-products-btn svg {
    width: 16px;
    height: 16px;
}

/* Modal Styles */
.ai-products-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

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

.ai-products-modal .modal-content {
    background: white;
    border-radius: 16px;
    width: 95%;
    height: 95vh;
    max-width: 1400px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    animation: slideUp 0.3s ease;
}

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

.ai-products-modal .modal-header {
    padding: 24px 30px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, var(--convertybot-primary, #007cba) 0%, #005a8a 100%);
    color: white;
    flex-shrink: 0;
}

.ai-products-modal .modal-header h3 {
    margin: 0;
    font-size: 24px;
    font-weight: 600;
}

.ai-products-modal .modal-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 28px;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 8px;
    transition: all 0.3s ease;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-products-modal .modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.ai-products-modal .modal-body {
    padding: 30px;
    flex: 1;
    overflow-y: auto;
    background: #f8f9fa;
}

.ai-products-modal .modal-body::-webkit-scrollbar {
    width: 10px;
}

.ai-products-modal .modal-body::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.ai-products-modal .modal-body::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 5px;
}

.ai-products-modal .modal-body::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.ai-products-modal .products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
}

@media (max-width: 768px) {
    .ai-products-modal .modal-content {
        width: 100%;
        height: 100%;
        border-radius: 0;
    }

    .ai-products-modal .products-grid {
        grid-template-columns: 1fr;
    }
}

.modal-product-card {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.modal-product-card:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    transform: translateY(-4px);
    border-color: var(--convertybot-primary, #007cba);
}

.modal-product-card img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    background: #f5f5f5;
}

.modal-product-card .no-image {
    width: 100%;
    height: 150px;
    background: #f5f5f5;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    border: 2px dashed #ddd;
}

.modal-product-card .product-info {
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.modal-product-card .product-info h5 {
    margin: 0 0 12px 0;
    font-size: 17px;
    font-weight: 600;
    color: #1a1a1a;
    line-height: 1.4;
    min-height: 48px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.modal-product-card .product-rating {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
}

.modal-product-card .product-rating .stars {
    color: #ffc107;
    font-size: 14px;
    letter-spacing: 1px;
}

.modal-product-card .product-rating .reviews {
    font-size: 12px;
    color: #666;
}

.modal-product-card .price {
    font-size: 18px;
    font-weight: bold;
    color: var(--convertybot-primary, #007cba);
    margin-bottom: 8px;
}

.modal-product-card .product-description {
    font-size: 13px;
    color: #666;
    line-height: 1.5;
    margin-bottom: 16px;
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.modal-product-card .product-actions {
    margin-top: auto;
}

.btn-view-product-modal {
    display: inline-block;
    padding: 12px 24px;
    background: var(--convertybot-primary, #007cba);
    color: white !important;
    text-decoration: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    transition: all 0.3s ease;
    width: 100%;
    text-align: center;
    box-sizing: border-box;
    border: none;
    cursor: pointer;
}

.btn-view-product-modal:hover {
    background: #005a8a;
    text-decoration: none;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 122, 186, 0.3);
    color: white !important;
}

.btn-view-product-modal.clicked {
    opacity: 0.7;
    pointer-events: none;
}

/* Mobile responsive */
@media (max-width: 480px) {
    .product-inline-content {
        flex-direction: column;
    }
    
    .product-inline-image {
        width: 100%;
        height: 120px;
    }
    
    .ai-products-modal .modal-content {
        width: 95%;
        margin: 10px;
    }
    
    .ai-products-modal .products-grid {
        grid-template-columns: 1fr;
    }
}
/* ===================================
   COUPON STYLES
   =================================== */

.ai-coupons-container {
    margin-top: 15px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ai-coupon-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    position: relative;
    overflow: hidden;
    animation: slideInCoupon 0.4s ease-out;
}

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

.ai-coupon-card::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
    animation: shimmer 3s infinite;
}

@keyframes shimmer {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(-30%, -30%); }
}

.coupon-badge {
    display: inline-block;
    background: rgba(255, 255, 255, 0.95);
    color: #764ba2;
    font-weight: bold;
    font-size: 18px;
    padding: 8px 16px;
    border-radius: 8px;
    margin-bottom: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    letter-spacing: 0.5px;
}

.coupon-content {
    position: relative;
    z-index: 1;
}

.coupon-title {
    color: white;
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 8px 0;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.coupon-description {
    color: rgba(255, 255, 255, 0.95);
    font-size: 14px;
    margin: 0 0 15px 0;
    line-height: 1.5;
}

.coupon-code-container {
    /* display: flex; */
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.15);
    border: 2px dashed rgba(255, 255, 255, 0.4);
    border-radius: 8px;
    padding: 12px 15px;
    margin-bottom: 10px;
    backdrop-filter: blur(10px);
}

.coupon-label {
    color: rgba(255, 255, 255, 0.9);
    font-size: 13px;
    font-weight: 500;
}

.coupon-code {
    flex: 1;
    color: white;
    font-family: 'Courier New', monospace;
    font-size: 16px;
    font-weight: bold;
    letter-spacing: 1px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.coupon-copy-btn {
    background: rgba(255, 255, 255, 0.25);
    border: none;
    border-radius: 6px;
    padding: 8px 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 21px;
    width: 40px;
}

.coupon-copy-btn svg {
    width: 18px;
    height: 18px;
    color: white;
}

.coupon-copy-btn:hover {
    background: rgba(255, 255, 255, 0.4);
    transform: scale(1.05);
}

.coupon-copy-btn.copied {
    background: rgba(76, 175, 80, 0.9);
}

.coupon-expiry {
    color: rgba(255, 255, 255, 0.85);
    font-size: 12px;
    margin: 0;
    font-style: italic;
}

/* Mobile responsive for coupons */
@media (max-width: 480px) {
    .ai-coupon-card {
        padding: 15px;
    }

    .coupon-badge {
        font-size: 16px;
        padding: 6px 12px;
    }

    .coupon-title {
        font-size: 16px;
    }

    .coupon-description {
        font-size: 13px;
    }

    .coupon-code {
        font-size: 14px;
    }

    .coupon-code-container {
        flex-wrap: wrap;
        padding: 10px;
    }

    .coupon-copy-btn {
        padding: 6px 10px;
    }
}
