* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #f5f5f5;
    min-height: 100vh;
    padding-bottom: 50px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
header {
    background: white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    margin-bottom: 30px;
}

.logo h1 {
    color: #333;
    font-size: 1.8em;
    margin-bottom: 5px;
}

.logo p {
    color: #888;
    font-size: 0.9em;
}

/* Search Bar */
.search-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    background: white;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

#searchInput {
    flex: 1;
    padding: 12px 20px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    font-size: 1em;
    outline: none;
    transition: border 0.3s;
}

#searchInput:focus {
    border-color: #333;
}

#searchBtn {
    padding: 12px 30px;
    background: #333;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1em;
    transition: all 0.3s;
}

#searchBtn:hover {
    background: #000;
}

/* Loading */
.loading {
    text-align: center;
    padding: 50px;
    color: #666;
}

.spinner {
    border: 4px solid #f0f0f0;
    border-top: 4px solid #333;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Products Grid */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 25px;
    margin-bottom: 30px;
}

.product-card {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    transition: all 0.3s;
    cursor: pointer;
}

.product-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.product-image {
    width: 100%;
    height: 250px;
    object-fit: cover;
    background: #f5f5f5;
}

.product-info {
    padding: 20px;
}

.product-store {
    display: inline-block;
    padding: 4px 10px;
    background: #333;
    color: white;
    border-radius: 4px;
    font-size: 0.75em;
    margin-bottom: 10px;
}

.product-name {
    font-size: 1em;
    font-weight: 600;
    color: #333;
    margin-bottom: 10px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-price {
    font-size: 1.2em;
    color: #333;
    font-weight: bold;
    margin-bottom: 10px;
}

.product-description {
    color: #666;
    font-size: 0.9em;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 15px;
}

.product-btn {
    width: 100%;
    padding: 10px;
    background: #333;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.95em;
    transition: all 0.3s;
}

.product-btn:hover {
    background: #000;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 30px;
}

.pagination button {
    padding: 10px 20px;
    background: white;
    border: 2px solid #667eea;
    color: #667eea;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
}

.pagination button:hover:not(:disabled) {
    background: #667eea;
    color: white;
}

.pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination button.active {
    background: #667eea;
    color: white;
}

/* Chat Widget */
.chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
}

.chat-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #333;
    color: white;
    border: none;
    font-size: 1.8em;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    transition: all 0.3s;
}

.chat-toggle:hover {
    transform: scale(1.05);
    background: #000;
}

.chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    height: 550px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-header {
    background: #333;
    color: white;
    padding: 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header h3 {
    margin: 0;
}

.chat-close {
    background: none;
    border: none;
    color: white;
    font-size: 1.5em;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
}

.chat-store-selector {
    padding: 15px;
    background: #f5f5f5;
    border-bottom: 1px solid #e0e0e0;
}

.chat-store-selector p {
    margin-bottom: 10px;
    font-weight: 600;
    color: #333;
}

.chat-store-btn {
    padding: 8px 15px;
    margin-right: 8px;
    margin-bottom: 8px;
    border: 2px solid #667eea;
    background: white;
    color: #667eea;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.3s;
}

.chat-store-btn:hover {
    background: #667eea;
    color: white;
}

.chat-store-btn.selected {
    background: #667eea;
    color: white;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f9f9f9;
}

.chat-message {
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
}

.chat-message.user {
    align-items: flex-end;
}

.chat-message.bot {
    align-items: flex-start;
}

.chat-message p {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 15px;
    margin: 0;
    word-wrap: break-word;
}

.chat-message.user p {
    background: #333;
    color: white;
    border-bottom-right-radius: 5px;
}

.chat-message.bot p {
    background: white;
    color: #333;
    border-bottom-left-radius: 5px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

/* Карточки товаров в чате */
.chat-product-carousel {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 10px 5px;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
}

.chat-product-carousel::-webkit-scrollbar {
    height: 6px;
}

.chat-product-carousel::-webkit-scrollbar-track {
    background: #f0f0f0;
    border-radius: 3px;
}

.chat-product-carousel::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.chat-product-carousel::-webkit-scrollbar-thumb:hover {
    background: #999;
}

.chat-product-card {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    min-width: 240px;
    max-width: 240px;
    scroll-snap-align: start;
    cursor: pointer;
    transition: all 0.3s;
    flex-shrink: 0;
}

.chat-product-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
}

.chat-product-image {
    width: 100%;
    height: 180px;
    object-fit: cover;
    background: #f5f5f5;
}

.chat-product-info {
    padding: 12px;
}

.chat-product-info h4 {
    margin: 0 0 8px 0;
    font-size: 0.95em;
    color: #333;
    font-weight: 600;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.chat-product-price {
    font-size: 1.1em;
    color: #333;
    font-weight: bold;
    margin: 5px 0;
}

.chat-product-detail {
    font-size: 0.85em;
    color: #666;
    margin: 3px 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

.chat-product-detail i {
    font-size: 0.9em;
}

.chat-input {
    display: flex;
    padding: 15px;
    background: white;
    border-top: 1px solid #e0e0e0;
}

#chatInput {
    flex: 1;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 25px;
    outline: none;
    font-size: 0.95em;
}

#chatInput:focus {
    border-color: #333;
}

#chatSend {
    width: 45px;
    height: 45px;
    margin-left: 10px;
    background: #333;
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2em;
    transition: all 0.3s;
}

#chatSend:hover:not(:disabled) {
    background: #000;
    transform: scale(1.05);
}

#chatSend:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Responsive */
@media (max-width: 768px) {
    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 15px;
    }
    
    .chat-window {
        width: calc(100vw - 40px);
        height: calc(100vh - 100px);
        bottom: 80px;
        right: 20px;
    }
    
    nav {
        justify-content: center;
    }
}


/* Модальное окно */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2000;
    animation: fadeIn 0.3s ease;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
}

.modal-content {
    position: relative;
    background: white;
    border-radius: 16px;
    max-width: 900px;
    width: 90%;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 1;
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    cursor: pointer;
    font-size: 1.2em;
    z-index: 10;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: rotate(90deg);
}

.modal-body {
    display: flex;
    overflow-y: auto;
    max-height: 90vh;
}

.modal-image {
    flex: 0 0 45%;
    background: #f5f5f5;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 30px;
}

.modal-image img {
    max-width: 100%;
    max-height: 500px;
    object-fit: contain;
    border-radius: 8px;
}

.modal-info {
    flex: 1;
    padding: 40px;
    overflow-y: auto;
}

.modal-info h2 {
    font-size: 1.8em;
    color: #333;
    margin-bottom: 15px;
    line-height: 1.3;
}

.modal-price {
    font-size: 2em;
    color: #333;
    font-weight: bold;
    margin-bottom: 25px;
}

.modal-details {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 25px;
    padding: 20px;
    background: #f9f9f9;
    border-radius: 8px;
}

.detail-item {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1em;
    color: #666;
}

.detail-item i {
    width: 24px;
    color: #333;
    font-size: 1.1em;
}

.modal-description {
    font-size: 1em;
    line-height: 1.6;
    color: #666;
    margin-bottom: 30px;
}

.modal-actions {
    display: flex;
    gap: 12px;
}

.btn-primary,
.btn-secondary {
    flex: 1;
    padding: 14px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background: #333;
    color: white;
}

.btn-primary:hover {
    background: #000;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.btn-secondary {
    background: #f0f0f0;
    color: #333;
}

.btn-secondary:hover {
    background: #e0e0e0;
}

/* Анимации */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(50px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Адаптив для модалки */
@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        max-height: 95vh;
    }
    
    .modal-body {
        flex-direction: column;
    }
    
    .modal-image {
        flex: 0 0 auto;
        padding: 20px;
    }
    
    .modal-image img {
        max-height: 300px;
    }
    
    .modal-info {
        padding: 20px;
    }
    
    .modal-info h2 {
        font-size: 1.4em;
    }
    
    .modal-price {
        font-size: 1.6em;
    }
    
    .modal-actions {
        flex-direction: column;
    }
}
