/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #FF6624 0%, #E55A1A 100%);
    height: 100vh;
    overflow: hidden;
}

/* Chat container */
.chat-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 400px;
    height: 600px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: all 0.3s ease;
    z-index: 1000;
}

.chat-container.minimized {
    height: 0;
    width: 0;
    opacity: 0;
    transform: scale(0);
}

/* Chat header */
.chat-header {
    background: linear-gradient(135deg, #FF6624 0%, #E55A1A 100%);
    color: white;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
}

.bot-avatar {
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.chat-info h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 5px;
}

.status {
    font-size: 12px;
    opacity: 0.8;
    display: flex;
    align-items: center;
    gap: 5px;
}

.status::before {
    content: '';
    width: 8px;
    height: 8px;
    background: #4ade80;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.chat-controls {
    margin-left: auto;
}

.minimize-btn {
    background: none;
    border: none;
    color: white;
    font-size: 16px;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background 0.3s ease;
}

.minimize-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Chat messages */
.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #f8fafc;
    scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

.message {
    display: flex;
    margin-bottom: 20px;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    flex-shrink: 0;
}

.bot-message .message-avatar {
    background: linear-gradient(135deg, #FF6624 0%, #E55A1A 100%);
    color: white;
}

.user-message {
    flex-direction: row-reverse;
}

.user-message .message-avatar {
    background: linear-gradient(135deg, #4ade80 0%, #22c55e 100%);
    color: white;
    margin-right: 0;
    margin-left: 12px;
}

.message-content {
    max-width: 80%;
    background: white;
    padding: 15px 20px;
    border-radius: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    position: relative;
}

.user-message .message-content {
    background: linear-gradient(135deg, #4ade80 0%, #22c55e 100%);
    color: white;
}

.message-content p {
    margin: 0;
    line-height: 1.6;
    word-wrap: break-word;
}

.message-content strong {
    font-weight: 600;
    color: inherit;
}

.message-content a {
    color: inherit;
    text-decoration: underline;
    opacity: 0.8;
}

.message-content a:hover {
    opacity: 1;
}

.message-time {
    font-size: 11px;
    opacity: 0.7;
    margin-top: 5px;
    display: block;
}

/* Chat input */
.chat-input-container {
    padding: 20px;
    background: white;
    border-top: 1px solid #e2e8f0;
}

.typing-indicator {
    display: none;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
    color: #64748b;
    font-size: 14px;
}

.typing-indicator.show {
    display: flex;
}

.typing-dots {
    display: flex;
    gap: 4px;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    background: #FF6624;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.typing-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

.chat-input {
    display: flex;
    gap: 10px;
    align-items: center;
}

#messageInput {
    flex: 1;
    padding: 15px 20px;
    border: 2px solid #e2e8f0;
    border-radius: 25px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.3s ease;
}

#messageInput:focus {
    border-color: #FF6624;
}

#sendButton {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #FF6624 0%, #E55A1A 100%);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 18px;
    cursor: pointer;
    transition: transform 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

#sendButton:hover {
    transform: scale(1.05);
}

#sendButton:active {
    transform: scale(0.95);
}

#sendButton:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Chat toggle button */
.chat-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #FF6624 0%, #E55A1A 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    z-index: 999;
}

.chat-toggle:hover {
    transform: scale(1.1);
}

.chat-toggle.hidden {
    display: none;
}

.notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ef4444;
    color: white;
    font-size: 12px;
    font-weight: bold;
    padding: 4px 8px;
    border-radius: 12px;
    min-width: 20px;
    text-align: center;
    display: none;
}

.notification-badge.show {
    display: block;
}

/* Responsive design */
@media (max-width: 768px) {
    .chat-container {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        border-radius: 0;
    }
    
    .chat-toggle {
        bottom: 20px;
        right: 20px;
    }
}

@media (max-width: 480px) {
    .chat-header {
        padding: 15px;
    }
    
    .chat-messages {
        padding: 15px;
    }
    
    .chat-input-container {
        padding: 15px;
    }
    
    .message-content {
        max-width: 85%;
        padding: 12px 16px;
    }
}

/* Loading animation */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Error message styling */
.error-message {
    background: #fee2e2 !important;
    color: #dc2626 !important;
    border-left: 4px solid #dc2626;
}

/* Success message styling */
.success-message {
    background: #dcfce7 !important;
    color: #16a34a !important;
    border-left: 4px solid #16a34a;
}

/* Product Analysis Styles */
.analysis-summary {
    background: linear-gradient(135deg, #FF6624 0%, #E55A1A 100%);
    color: white;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 20px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.analysis-summary h3 {
    margin: 0 0 10px 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.analysis-stats {
    margin: 0;
    font-size: 0.85rem;
    opacity: 0.9;
}

.product-results {
    padding: 15px 0;
}

.product-results h4 {
    margin: 0 0 15px 0;
    color: #495057;
    font-size: 1rem;
    font-weight: 600;
}

.showing-info {
    color: #6c757d;
    font-size: 0.8rem;
    margin: 0 0 15px 0;
    font-style: italic;
}

.show-all-section {
    background: #e3f2fd;
    border: 1px solid #bbdefb;
    border-radius: 6px;
    padding: 15px;
    margin-top: 20px;
    text-align: center;
}

.show-all-message {
    color: #1976d2;
    margin: 0 0 10px 0;
    font-weight: 500;
    font-size: 0.85rem;
}

.show-all-instruction {
    color: #424242;
    margin: 0;
    font-size: 0.8rem;
}

.product-list {
    display: flex;
    flex-direction: column;
}

.product-item {
    padding: 6px 0;
    border-bottom: 1px solid #e9ecef;
    line-height: 1.3;
    font-size: 0.85rem;
}

.product-item:last-child {
    border-bottom: none;
}

.product-name {
    font-weight: 600;
    color: #212529;
    margin-bottom: 6px;
    font-size: 0.9rem;
}

.product-details {
    display: flex;
    gap: 15px;
    margin-bottom: 6px;
    align-items: center;
}

.price {
    color: #28a745;
    font-weight: 600;
    font-size: 0.95rem;
}

.uom {
    color: #6c757d;
    font-size: 0.8rem;
}

.product-category {
    color: #6c757d;
    font-size: 0.75rem;
    font-style: italic;
}

.analysis-breakdown, .brand-analysis, .price-range {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

.analysis-breakdown h4, .brand-analysis h4, .price-range h4 {
    margin: 0 0 15px 0;
    color: #495057;
    font-size: 1rem;
    font-weight: 600;
}

.category-list, .brand-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.category-item, .brand-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: white;
    border-radius: 4px;
    border: 1px solid #e9ecef;
}

.category-name, .brand-name {
    font-weight: 500;
    color: #495057;
}

.category-count, .brand-count {
    color: #6c757d;
    font-size: 0.8rem;
}

.price-info {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: center;
    padding: 15px;
    background: white;
    border-radius: 6px;
    border: 1px solid #e9ecef;
}

.price-min, .price-max {
    font-weight: 600;
    color: #28a745;
    font-size: 0.95rem;
}

.price-separator {
    color: #6c757d;
    font-weight: 500;
}

.contact-info {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
    padding: 20px;
    border-radius: 12px;
    margin-top: 20px;
}

.contact-info h4 {
    margin: 0 0 15px 0;
    font-size: 1rem;
    font-weight: 600;
}

.contact-details {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.contact-item {
    display: flex;
    gap: 10px;
    align-items: center;
}

.contact-label {
    font-weight: 600;
    min-width: 60px;
}

.contact-value {
    opacity: 0.9;
}

.contact-value a {
    color: white;
    text-decoration: underline;
}

.contact-value a:hover {
    text-decoration: none;
}

/* No Results Styles */
.no-results {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 30px;
    text-align: center;
}

.no-results h3 {
    color: #dc3545;
    margin: 0 0 15px 0;
    font-size: 1.1rem;
}

.no-results-message {
    color: #6c757d;
    margin: 0 0 25px 0;
    font-size: 0.85rem;
}

.search-suggestions {
    margin-bottom: 25px;
}

.search-suggestions h4 {
    color: #495057;
    margin: 0 0 15px 0;
    font-size: 0.95rem;
}

.suggestion-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.suggestion-item {
    background: white;
    padding: 10px 15px;
    border-radius: 4px;
    border: 1px solid #e9ecef;
    color: #495057;
    font-size: 0.8rem;
}

.catalog-link h4 {
    color: #495057;
    margin: 0 0 15px 0;
    font-size: 0.95rem;
}

.catalog-button {
    display: inline-block;
    background: #007bff;
    color: white;
    padding: 12px 24px;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 600;
    transition: background-color 0.2s ease;
}

.catalog-button:hover {
    background: #0056b3;
    color: white;
    text-decoration: none;
}

/* Fallback Response Styles */
.fallback-response {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 25px;
}

.fallback-response h3 {
    color: #495057;
    margin: 0 0 15px 0;
    font-size: 1.1rem;
}

.fallback-message {
    color: #6c757d;
    margin: 0 0 20px 0;
    font-size: 0.85rem;
}

.help-options {
    margin-bottom: 25px;
}

.help-item {
    background: white;
    padding: 10px 15px;
    margin-bottom: 8px;
    border-radius: 4px;
    border: 1px solid #e9ecef;
    color: #495057;
    font-size: 0.8rem;
}

.website-link p {
    color: #6c757d;
    margin: 0 0 10px 0;
    font-size: 0.8rem;
}

.website-button {
    display: inline-block;
    background: #6c757d;
    color: white;
    padding: 10px 20px;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 500;
    transition: background-color 0.2s ease;
}

.website-button:hover {
    background: #5a6268;
    color: white;
    text-decoration: none;
}

/* Category and Offer Styles */
.category-item {
    background: white;
    padding: 8px 12px;
    margin-bottom: 6px;
    border-radius: 4px;
    border: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.category-item strong {
    color: #495057;
    font-size: 0.85rem;
}

.category-count {
    color: #6c757d;
    font-size: 0.75rem;
}

.offer-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 20px;
}

.offer-item {
    background: white;
    padding: 15px;
    border-radius: 6px;
    border: 1px solid #e9ecef;
}

.offer-item h5 {
    color: #495057;
    margin: 0 0 8px 0;
    font-size: 0.9rem;
    font-weight: 600;
}

.offer-item p {
    color: #6c757d;
    margin: 0;
    font-size: 0.8rem;
    line-height: 1.4;
}

/* Enhanced Responsive Design */
@media (max-width: 768px) {
    .product-details {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }
    
    .contact-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }
    
    .price-info {
        flex-direction: column;
        gap: 5px;
    }
    
    .analysis-summary, .product-results, .analysis-breakdown, 
    .brand-analysis, .price-range, .contact-info, .no-results, 
    .fallback-response {
        padding: 15px;
        margin-bottom: 15px;
    }
}