/*
Theme Name: Stanki Catalog
Theme URI: https://example.com/
Author: Your Name
Author URI: https://example.com/
Description: Профессиональная тема для каталога промышленного оборудования с мультивалютностью и расширенными возможностями
Version: 1.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: stanki-catalog
Tags: e-commerce, catalog, industrial, multi-currency, responsive
*/

/* ==========================================================================
   Reset & Base Styles
   ========================================================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #d32f2f;
    --secondary-color: #1976d2;
    --text-color: #333;
    --light-gray: #f5f5f5;
    --border-color: #ddd;
    --white: #fff;
    --header-bg: #fff;
    --footer-bg: #2c3e50;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: #fff;
}

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

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

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

/* ==========================================================================
   Container & Layout
   ========================================================================== */

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.container-fluid {
    width: 100%;
    padding: 0 20px;
}

/* ==========================================================================
   Header Styles
   ========================================================================== */

.site-header {
    background: var(--header-bg);
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.top-bar {
    background: var(--light-gray);
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
}

.top-bar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

.currency-switcher {
    display: flex;
    gap: 10px;
    align-items: center;
}

.currency-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    padding: 5px 12px;
    cursor: pointer;
    border-radius: 4px;
    font-size: 14px;
    transition: all 0.3s ease;
}

.currency-btn:hover,
.currency-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.contact-info {
    display: flex;
    gap: 20px;
    align-items: center;
    flex-wrap: wrap;
}

.phone {
    font-weight: bold;
    font-size: 18px;
    color: var(--primary-color);
}

.header-main {
    padding: 20px 0;
}

.header-main .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.site-logo a {
    font-size: 24px;
    font-weight: bold;
    color: var(--primary-color);
    text-transform: uppercase;
}

.site-logo span {
    color: var(--text-color);
}

.header-search {
    flex: 1;
    max-width: 500px;
}

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

.search-form input[type="search"] {
    flex: 1;
    border: none;
    padding: 12px 15px;
    font-size: 14px;
    outline: none;
}

.search-form button {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 12px 25px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.3s ease;
}

.search-form button:hover {
    background: #b71c1c;
}

/* ==========================================================================
   Navigation Menu
   ========================================================================== */

.main-navigation {
    background: var(--primary-color);
}

.nav-menu {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
}

.nav-menu > li {
    position: relative;
}

.nav-menu > li > a {
    display: block;
    padding: 15px 20px;
    color: white;
    font-weight: 500;
    transition: background 0.3s ease;
}

.nav-menu > li > a:hover,
.nav-menu > li.current-menu-item > a {
    background: rgba(0,0,0,0.2);
}

/* Dropdown Menu */
.nav-menu .sub-menu {
    position: absolute;
    top: 100%;
    left: 0;
    background: white;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    list-style: none;
    min-width: 250px;
    display: none;
    z-index: 100;
}

.nav-menu li:hover > .sub-menu {
    display: block;
}

.nav-menu .sub-menu li a {
    display: block;
    padding: 12px 20px;
    color: var(--text-color);
    border-bottom: 1px solid var(--border-color);
}

.nav-menu .sub-menu li a:hover {
    background: var(--light-gray);
    color: var(--primary-color);
}

/* Mobile Menu Toggle */
.mobile-menu-toggle {
    display: none;
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 10px 20px;
    cursor: pointer;
    font-size: 18px;
}

/* ==========================================================================
   Product Grid & Catalog
   ========================================================================== */

.catalog-section {
    padding: 40px 0;
}

.section-title {
    font-size: 28px;
    margin-bottom: 30px;
    padding-bottom: 15px;
    border-bottom: 3px solid var(--primary-color);
    position: relative;
}

.section-title::before {
    content: '';
    position: absolute;
    bottom: -3px;
    left: 0;
    width: 100px;
    height: 3px;
    background: var(--secondary-color);
}

.catalog-filters {
    background: var(--light-gray);
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 30px;
}

.filter-group {
    margin-bottom: 15px;
}

.filter-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
}

.filter-group select,
.filter-group input {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px;
}

.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 30px;
    margin-top: 30px;
}

.product-card {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s ease;
    position: relative;
}

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

.product-image {
    width: 100%;
    height: 250px;
    overflow: hidden;
    position: relative;
    background: var(--light-gray);
}

.product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    /* Анти-мыло: при transform/scale без принудительной растеризации
       браузер размывает картинку. translateZ(0) + backface-visibility
       форсирует резкий рендер на GPU. */
    transition: transform 0.4s ease;
    transform: translateZ(0);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

.product-card:hover .product-image img {
    transform: translateZ(0) scale(1.06);
}

.product-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: var(--primary-color);
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
}

.product-info {
    padding: 20px;
}

.product-category {
    font-size: 12px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.product-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 10px;
    line-height: 1.4;
    min-height: 44px;
}

.product-title a {
    color: var(--text-color);
}

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

.product-description {
    font-size: 14px;
    color: #666;
    margin-bottom: 15px;
    line-height: 1.5;
}

.product-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid var(--border-color);
}

.product-price {
    font-size: 20px;
    font-weight: bold;
    color: var(--primary-color);
}

.stock-status {
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 4px;
    background: #4caf50;
    color: white;
}

.stock-status.out-of-stock {
    background: #f44336;
}

.product-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    transition: all 0.3s ease;
    display: inline-block;
}

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

.btn-primary:hover {
    background: #b71c1c;
    color: white;
}

.btn-secondary {
    background: white;
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
}

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

/* ==========================================================================
   Sidebar
   ========================================================================== */

.content-area {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 30px;
    margin-top: 30px;
}

/* Одна колонка контента без сайдбара — иначе grid оставляет ~280px (перенос на хостинг без виджетов в сайдбаре) */
.content-area > .primary-content:only-child {
    grid-column: 1 / -1;
    min-width: 0;
}

.sidebar {
    background: var(--light-gray);
    padding: 20px;
    border-radius: 8px;
    height: fit-content;
}

.widget {
    margin-bottom: 30px;
}

.widget:last-child {
    margin-bottom: 0;
}

.widget-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--primary-color);
}

.widget ul {
    list-style: none;
}

.widget ul li {
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

.widget ul li:last-child {
    border-bottom: none;
}

.widget ul li a {
    color: var(--text-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.widget ul li a:hover {
    color: var(--primary-color);
    padding-left: 5px;
}

.category-count {
    background: var(--primary-color);
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
}

/* ==========================================================================
   Footer
   ========================================================================== */

.site-footer {
    background: var(--footer-bg);
    color: white;
    padding: 40px 0 20px;
    margin-top: 60px;
}

.footer-widgets {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 30px;
    margin-bottom: 30px;
}

.footer-widget h3 {
    font-size: 18px;
    margin-bottom: 20px;
    color: white;
}

.footer-widget ul {
    list-style: none;
}

.footer-widget ul li {
    margin-bottom: 10px;
}

.footer-widget ul li a {
    color: rgba(255,255,255,0.8);
}

.footer-widget ul li a:hover {
    color: white;
}

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

/* ==========================================================================
   Reviews Section
   ========================================================================== */

.reviews-section {
    background: var(--light-gray);
    padding: 40px 0;
    margin-top: 40px;
}

.reviews-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 30px;
}

.review-card {
    background: white;
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.review-rating {
    color: #ffa000;
    font-size: 20px;
    margin-bottom: 10px;
}

.review-author {
    font-weight: 600;
    margin-bottom: 5px;
}

.review-date {
    font-size: 12px;
    color: #888;
    margin-bottom: 15px;
}

.review-text {
    line-height: 1.6;
    color: #555;
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */

@media (max-width: 968px) {
    .content-area {
        grid-template-columns: 1fr;
    }
    
    .sidebar {
        order: -1;
    }
    
    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        gap: 20px;
    }
}

@media (max-width: 768px) {
    /* Шапка не фиксируется на мобильных — занимает много места при скролле.
       Прокручивается вместе со страницей. На десктопе остаётся sticky. */
    .site-header {
        position: static;
        top: auto;
    }
    .site-header.sticky {
        position: static;
        box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    }

    .mobile-menu-toggle {
        display: block;
        position: relative;
        z-index: 10001;
    }
    
    .main-navigation {
        position: relative;
    }
    
    /* Мобильное меню зафиксировано во вьюпорте под шапкой и не скроллится
       вместе со страницей. Под открытым меню скролл body заблокирован
       классом body.mobile-menu-open ниже. */
    .nav-menu {
        display: none;
        flex-direction: column;
        position: fixed;
        top: var(--mobile-menu-top, 0);
        left: 0;
        right: 0;
        bottom: 0;
        background: var(--primary-color);
        z-index: 10000;
        margin: 0;
        padding: 0;
        overflow: hidden; /* меню целиком не скроллится */
        overscroll-behavior: contain;
    }
    
    .nav-menu.active {
        display: flex;
    }
    
    /* Если пунктов реально много и они не влезают — даём прокрутку
       только содержимому меню, а не всей странице. */
    .nav-menu.active.is-overflowing {
        overflow-y: auto;
    }
    
    .nav-menu .sub-menu {
        position: static;
        box-shadow: none;
        background: rgba(0,0,0,0.2);
    }
    
    /* Блокировка прокрутки страницы при открытом мобильном меню. */
    body.mobile-menu-open {
        overflow: hidden;
        touch-action: none;
    }
    
    .header-main .container {
        flex-direction: column;
    }
    
    .header-search {
        width: 100%;
        max-width: 100%;
    }
    
    .products-grid {
        grid-template-columns: 1fr;
    }
    
    .footer-widgets {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .top-bar .container {
        flex-direction: column;
        gap: 10px;
    }
    
    .contact-info {
        flex-direction: column;
        gap: 10px;
    }
    
    .product-actions {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
    }
}

/* ==========================================================================
   Utility Classes
   ========================================================================== */

.text-center {
    text-align: center;
}

.mt-20 {
    margin-top: 20px;
}

.mb-20 {
    margin-bottom: 20px;
}

.hidden {
    display: none;
}
