:root {
    --primary-color: #3498db;
    --secondary-color: #2ecc71;
    --dark-color: #2c3e50;
    --light-color: #ecf0f1;
    --danger-color: #e74c3c;
    --warning-color: #f39c12;
    --success-color: #27ae60;
    --info-color: #3498db;
}

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

main {
    flex: 1;
}

/* Карточки товаров */
.product-card {
    height: 100%;
    transition: transform 0.3s, box-shadow 0.3s;
    border-radius: 10px;
    overflow: hidden;
}

.product-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}

.product-image {
    height: 200px;
    object-fit: cover;
}

.product-price {
    font-weight: bold;
    color: var(--dark-color);
}

.product-old-price {
    text-decoration: line-through;
    color: #999;
    font-size: 0.9em;
}

.product-discount {
    background-color: var(--danger-color);
    color: white;
    padding: 0.2rem 0.5rem;
    border-radius: 3px;
    font-size: 0.8em;
}

/* Рейтинг звезд */
.rating {
    display: inline-flex;
    color: var(--warning-color);
}

.rating-form .rating {
    cursor: pointer;
}

/* Кнопки */
.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-secondary {
    background-color: var(--secondary-color);
    border-color: var(--secondary-color);
}

.btn-outline-primary {
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-outline-primary:hover {
    background-color: var(--primary-color);
    color: white;
}

/* Фильтры и сортировка */
.filters-sidebar {
    position: sticky;
    top: 20px;
}

/* Корзина и список желаний */
.cart-item, .wishlist-item {
    padding: 15px;
    margin-bottom: 10px;
    border-radius: 5px;
    background-color: #f9f9f9;
}

.item-quantity {
    width: 70px;
}

/* Отзывы */
.review-item {
    padding: 15px;
    margin-bottom: 15px;
    border-radius: 5px;
    background-color: #f9f9f9;
}

.review-images {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
}

.review-image {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 5px;
    cursor: pointer;
}

/* Модальные окна */
.modal-backdrop {
    z-index: 1040;
}

.modal {
    z-index: 1050;
}

/* ИИ-ассистент */
.ai-assistant-wrapper {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
}

.ai-assistant-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-assistant-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
}

.ai-assistant-button:active {
    transform: translateY(0);
}

.ai-assistant-chat {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 350px;
    height: 500px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #e0e0e0;
}

@media (max-width: 480px) {
    .ai-assistant-chat {
        width: 320px;
        height: 450px;
        bottom: 70px;
        right: -10px;
    }

    .ai-assistant-wrapper {
        bottom: 15px;
        right: 15px;
    }
}

.chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

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

.btn-close-white {
    background: transparent;
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-close-white:hover {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
}

.connection-status {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    padding: 5px 10px;
    font-size: 12px;
    text-align: center;
    display: none;
}

.connection-status.connecting {
    background: #ffc107;
    color: #000;
}

.connection-status.connected {
    background: #28a745;
    color: white;
}

.connection-status.error {
    background: #dc3545;
    color: white;
}

.chat-messages {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    background: #f8f9fa;
}

.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 {
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
}

.user-message {
    align-items: flex-end;
}

.ai-message {
    align-items: flex-start;
}

.system-message {
    align-items: center;
}

.message-content {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
}

.user-message .message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.ai-message .message-content {
    background: white;
    color: #333;
    border: 1px solid #e0e0e0;
    border-bottom-left-radius: 4px;
}

.system-message .message-content {
    background: #f0f0f0;
    color: #666;
    font-style: italic;
    font-size: 12px;
    max-width: 90%;
    text-align: center;
}

.message-time {
    font-size: 11px;
    color: #999;
    margin-top: 4px;
    padding: 0 4px;
}

.user-message .message-time {
    text-align: right;
}

.ai-message .message-time {
    text-align: left;
}

.chat-input {
    padding: 15px;
    background: white;
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 10px;
}

.chat-input input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 10px 15px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.3s ease;
}

.chat-input input:focus {
    border-color: #667eea;
}

.chat-input button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.chat-input button:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.chat-input button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Search Results Styles */
.search-results-container {
    margin-top: 10px;
}

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

.product-card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border-color: #667eea;
}

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

.product-image {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
}

.product-placeholder {
    width: 60px;
    height: 60px;
    background: #f0f0f0;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
}

.product-details {
    flex: 1;
    min-width: 0;
}

.product-name {
    margin: 0 0 6px 0;
    font-size: 13px;
    font-weight: 600;
    color: #333;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-price {
    font-size: 14px;
    font-weight: 700;
    color: #28a745;
    margin-bottom: 4px;
}

.product-old-price {
    font-size: 12px;
    color: #999;
    text-decoration: line-through;
    margin-bottom: 6px;
}

.product-link {
    display: inline-block;
    padding: 4px 8px;
    background: #667eea;
    color: white;
    text-decoration: none;
    border-radius: 4px;
    font-size: 12px;
    transition: background-color 0.3s ease;
}

.product-link:hover {
    background: #5a6fd8;
    color: white;
    text-decoration: none;
}

/* AI Hint Styles */
.ai-hint {
    position: absolute;
    bottom: 70px;
    right: 0;
    background: white;
    padding: 10px 15px;
    border-radius: 10px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
    max-width: 250px;
    cursor: pointer;
    font-size: 14px;
    line-height: 1.4;
    border: 1px solid #e0e0e0;
    animation: fadeInUp 0.3s ease;
    z-index: 999;
}

.ai-hint:hover {
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.25);
    transform: translateY(-2px);
}

.ai-hint::before {
    content: '';
    position: absolute;
    bottom: -6px;
    right: 20px;
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid white;
}

.ai-hint::after {
    content: '';
    position: absolute;
    bottom: -7px;
    right: 20px;
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid #e0e0e0;
    z-index: -1;
}

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

/* Loading Animation */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    max-width: 60px;
}

.typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #999;
    animation: typingAnimation 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) {
    animation-delay: -0.32s;
}

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

@keyframes typingAnimation {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .ai-assistant-chat {
        background: #2d3748;
        border-color: #4a5568;
    }

    .chat-messages {
        background: #1a202c;
    }

    .ai-message .message-content {
        background: #2d3748;
        color: #e2e8f0;
        border-color: #4a5568;
    }

    .chat-input {
        background: #2d3748;
        border-color: #4a5568;
    }

    .chat-input input {
        background: #1a202c;
        color: #e2e8f0;
        border-color: #4a5568;
    }

    .product-card {
        background: #2d3748;
        border-color: #4a5568;
    }

    .product-name {
        color: #e2e8f0;
    }

    .ai-hint {
        background: #2d3748;
        color: #e2e8f0;
        border-color: #4a5568;
    }

    .ai-hint::before {
        border-top-color: #2d3748;
    }

    .ai-hint::after {
        border-top-color: #4a5568;
    }
}

/* Accessibility improvements */
.ai-assistant-button:focus,
.chat-input button:focus,
.chat-input input:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

.product-link:focus {
    outline: 2px solid #667eea;
    outline-offset: 1px;
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .ai-assistant-button,
    .chat-input button {
        background: #000;
        border: 2px solid #fff;
    }

    .ai-message .message-content {
        border-width: 2px;
    }

    .product-card {
        border-width: 2px;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .ai-assistant-button,
    .chat-input button,
    .product-card,
    .ai-hint {
        transition: none;
    }

    .typing-dot {
        animation: none;
    }

    @keyframes fadeInUp {
        from, to {
            opacity: 1;
            transform: translateY(0);
        }
    }
}