/* Основные стили маркетплейса */

/* Переменные */
:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --success-color: #22c55e;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --text-light: #9ca3af;
    --bg-primary: #ffffff;
    --bg-secondary: #f3f4f6;
    --bg-dark: #1f2937;
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --transition: all 0.3s ease;
}

/* Сброс стилей */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
    background-color: var(--bg-secondary);
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--primary-hover);
}

img {
    max-width: 100%;
    height: auto;
}

ul, ol {
    list-style: none;
}

/* Контейнер */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
.main-header {
    background: var(--bg-primary);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 15px 0;
}

.logo img {
    height: 50px;
}

.search-box {
    flex: 1;
    /* Без фиксированного max-width: занимает всё свободное место,
       чтобы шапка по ширине совпадала с основным контейнером. */
    max-width: none;
}

.search-form {
    display: flex;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.search-input {
    flex: 1;
    padding: 10px 15px;
    border: none;
    font-size: 14px;
    outline: none;
}

.search-input:focus {
    border-color: var(--primary-color);
}

.search-btn {
    padding: 10px 15px;
    background: var(--primary-color);
    border: none;
    cursor: pointer;
    transition: var(--transition);
}

.search-btn:hover {
    background: var(--primary-hover);
}

.search-btn img {
    width: 20px;
    height: 20px;
    filter: invert(1);
}

/* Кнопка «Каталог» в шапке — между логотипом и поиском.
   Размер увеличен в 1.5 раза от исходного для более выразительного CTA. */
.catalog-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 30px;
    min-width: 150px;
    background: var(--primary-color);
    color: #fff;
    font-size: 15px;
    font-weight: 500;
    text-decoration: none;
    border-radius: var(--radius-lg);
    white-space: nowrap;
    transition: var(--transition);
}

.catalog-btn:hover {
    background: var(--primary-hover);
    color: #fff;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 15px;
}

.menu-link {
    display: flex;
    align-items: center;
    gap: 5px;
    color: var(--text-primary);
    font-size: 14px;
}

.menu-link:hover {
    color: var(--primary-color);
}

.menu-link img {
    width: 24px;
    height: 24px;
}

.cart-link {
    position: relative;
}

.cart-count {
    position: absolute;
    top: -8px;
    right: -8px;
    background: var(--danger-color);
    color: white;
    font-size: 11px;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

/* Категории */
.categories-nav {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
}

.categories-list {
    display: flex;
    gap: 10px;
    padding: 10px 0;
    overflow-x: auto;
}

.categories-list li a {
    display: block;
    padding: 8px 16px;
    background: var(--bg-primary);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-weight: 500;
    white-space: nowrap;
    transition: var(--transition);
}

.categories-list li a:hover {
    background: var(--primary-color);
    color: white;
}

/* Основной контент */
.main-content {
    min-height: calc(100vh - 200px);
    padding: 30px 0;
}

/* Flash-сообщения */
.flash-container {
    margin-top: 20px;
    margin-bottom: 0;
    padding: 0 15px;
}
.flash-container .flash {
    margin-bottom: 10px;
    border-radius: var(--radius-md, 8px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* Карточка товара */
.product-card {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: var(--transition);
}

.product-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.product-card-inner {
    display: flex;
    flex-direction: column;
}

.product-photo {
    position: relative;
    display: block;
    aspect-ratio: 1 / 1.5;
    background: #ffffff;
    overflow: hidden;
}

.product-photo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #ffffff;
}

.product-photo-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-light);
}

.product-badges {
    position: absolute;
    top: 10px;
    left: 10px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.badge {
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
}

.badge-new {
    background: var(--success-color);
    color: white;
}

.badge-sale {
    background: var(--danger-color);
    color: white;
}

.favorite-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    opacity: 0;
    z-index: 10;
}

.product-card:hover .favorite-btn {
    opacity: 1;
}

/* Активная кнопка избранного (красное сердечко) всегда видима */
.favorite-btn.active {
    opacity: 1;
    z-index: 10;
}

/* Неактивная кнопка избранного показывается только при наведении */
.product-card:hover .favorite-btn:not(.active) {
    opacity: 1;
}

/* Анимация удаления карточки из избранного */
.product-card.removing {
    transition: opacity 0.3s ease, transform 0.3s ease, margin 0.3s ease, padding 0.3s ease;
    overflow: hidden;
}

.favorite-btn:hover {
    background: white;
    transform: scale(1.1);
}

.favorite-btn.active svg path {
    fill: var(--danger-color);
}

.product-info {
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.product-name {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    min-height: 22px;
}

.product-name:hover {
    color: var(--primary-color);
}

.product-price {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
}

.current-price {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.old-price {
    font-size: 13px;
    color: var(--text-light);
    text-decoration: line-through;
    line-height: 1.2;
}

.product-rating {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 13px;
}

.rating-stars {
    color: #fbbf24;
}

.rating-stars .star {
    color: #fbbf24;
}

.star.filled {
    color: #fbbf24;
}

.star:not(.filled) {
    color: #fbbf24;
}

.rating-value {
    font-weight: 600;
}

.reviews-count {
    color: var(--text-secondary);
}

/* Сетка товаров */
.products-grid {
    display: grid;
    gap: 20px;
}

.products-grid-5 {
    grid-template-columns: repeat(5, 1fr);
}

.products-grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

.products-grid-2 {
    grid-template-columns: repeat(2, 1fr);
}

/* Адаптивность */
@media (max-width: 1024px) {
    .products-grid-5 {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 768px) {
    .header-inner {
        flex-wrap: wrap;
    }
    
    .search-box {
        order: 3;
        max-width: 100%;
        width: 100%;
    }
    
    .products-grid-5,
    .products-grid-4 {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 480px) {
    .products-grid-5,
    .products-grid-4,
    .products-grid-3 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .categories-list {
        gap: 5px;
    }
    
    .categories-list li a {
        padding: 6px 12px;
        font-size: 13px;
    }
}

/* Кнопки */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

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

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

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

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

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-block {
    width: 100%;
}

/* Формы */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-primary);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 14px;
    transition: var(--transition);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.form-options {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: auto;
}

/* Footer */
.main-footer {
    background: var(--bg-dark);
    color: white;
    padding: 50px 0 20px;
    margin-top: 50px;
}

.footer-inner {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 40px;
    margin-bottom: 40px;
}

.footer-column h4 {
    margin-bottom: 20px;
    font-size: 16px;
    font-weight: 600;
}

/* Соцсети в подвале: одна ссылка должна быть отцентрирована, много — равномерно. */
.footer-column.social-column {
    text-align: center;
}
.footer-column.social-column h4 {
    text-align: center;
}

.footer-column ul {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.footer-column a {
    color: #9ca3af;
    font-size: 14px;
}

.footer-column a:hover {
    color: white;
}

.social-links,
.marketplace-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
}

.social-link,
.marketplace-link {
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    color: white;
    font-size: 13px;
}

.footer-bottom {
    text-align: center;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    color: #9ca3af;
}

/* Flash messages */
.flash-messages {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.flash-message {
    padding: 15px 20px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease;
}

.flash-message.success {
    background: var(--success-color);
    color: white;
}

.flash-message.error {
    background: var(--danger-color);
    color: white;
}

.flash-message.warning {
    background: var(--warning-color);
    color: white;
}

.flash-message.info {
    background: var(--primary-color);
    color: white;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Секции */
.products-section {
    margin-bottom: 50px;
}

.section-header {
    margin-bottom: 20px;
}

.section-header h2 {
    font-size: 24px;
    font-weight: 700;
}

.section-header h2 a {
    color: var(--text-primary);
}

.section-header h2 a:hover {
    color: var(--primary-color);
}

/* Акции */
.promotions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
}

.promotion-card {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 20px;
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.promotion-icon {
    width: 60px;
    height: 60px;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--bg-secondary);
}

.promotion-icon-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: bold;
    color: var(--primary-color);
}

.promotion-info h3 {
    font-size: 16px;
    margin-bottom: 5px;
}

.promotion-info p {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.promotion-badge {
    display: inline-block;
    padding: 4px 8px;
    background: var(--danger-color);
    color: white;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
}

/* Корзина - изображения товаров */
.cart-item-image {
    width: 70px;
    height: 70px;
    min-width: 70px;
    border-radius: 6px;
    overflow: hidden;
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.cart-item-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cart-item-image .no-image {
    color: var(--text-light);
    font-size: 12px;
    text-align: center;
}
