/* Base Reset & Fonts */
:root {
    --primary: #f97316;
    --primary-hover: #ea580c;
    --bg-light: #f9fafb;
    --text-dark: #1f2937;
    --text-gray: #6b7280;
    --header-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; }

body {
    font-family: 'Inter', sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--bg-light);
    color: var(--text-dark);
}

a { text-decoration: none; color: inherit; }
ul { list-style: none; padding: 0; margin: 0; }
button { font-family: inherit; }

/* Sticky Header System */
.sticky-container {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: transparent; /* Wrapper is transparent */
}

/* 1. Top Bar (Not sticky? User said "toggle must be sticky". Usually whole header is sticky). 
   Let's make Main Header + Toggle sticky. 
   User said: "toggle... sticky... without white strip... simple fix make white strip transparent... shadow on white box above".
*/

.main-header-block {
    background: white;
    box-shadow: var(--header-shadow);
    position: relative;
    z-index: 1001;
}

.top-bar {
    border-bottom: 1px solid #f3f4f6;
    padding: 0.5rem 2rem;
    font-size: 0.85rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-gray);
}

.social-links {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.social-icon {
    width: 20px;
    height: 20px;
    transition: transform 0.2s;
}
.social-icon:hover { transform: scale(1.1); }

.main-header {
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
}

.logo {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.search-bar {
    flex-grow: 1;
    max-width: 600px;
}

.search-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    background: #f9fafb;
    outline: none;
    transition: var(--transition);
    font-size: 1rem;
}
.search-input:focus {
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.1);
}

.header-actions {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.cart-btn {
    position: relative;
    cursor: pointer;
    font-size: 1.5rem;
    transition: transform 0.2s;
}
.cart-btn:hover { transform: scale(1.1); }

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

/* 2. Transparent Toggle Bar (Sticky Sub-nav) */
.sub-header {
    background: transparent;
    padding: 0.5rem 2rem;
    display: flex;
    align-items: center;
    justify-content: center; /* Default Centered */
    gap: 1.5rem;
    pointer-events: none;
    margin-bottom: 1rem;
    transition: all 0.5s ease;
}

.sub-header.left-aligned {
    justify-content: flex-start;
}

/* Segmented Control Toggle */
.mode-toggle {
    pointer-events: auto;
    background: #f3f4f6; /* Gray track */
    padding: 0.25rem;
    border-radius: 9999px; /* Pill shape */
    display: inline-flex;
    position: relative;
    border: 1px solid #e5e7eb;
    box-shadow: inset 0 2px 4px 0 rgba(0, 0, 0, 0.05);
}

/* Sliding Background Pill */
.mode-toggle::before {
    content: '';
    position: absolute;
    top: 0.25rem;
    bottom: 0.25rem;
    left: 0.25rem;
    width: calc(50% - 0.25rem); /* Assume equal width buttons */
    background: white;
    border-radius: 9999px;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
    z-index: 0;
}

/* Move slider based on state class added to parent */
.mode-toggle.show-types::before {
    transform: translateX(100%);
}

.toggle-btn {
    position: relative;
    z-index: 1; /* Above the slider */
    flex: 1;
    padding: 0.5rem 1.5rem;
    border: none;
    background: transparent;
    cursor: pointer;
    font-weight: 600;
    color: var(--text-gray);
    transition: color 0.2s;
    font-size: 0.9rem;
    border-radius: 9999px;
    white-space: nowrap;
}

.toggle-btn.active {
    color: var(--text-dark); /* Active text color */
    /* Background is handled by ::before */
    box-shadow: none; 
    background: transparent;
}
.toggle-btn:hover:not(.active) {
    color: var(--text-dark);
}

/* Spacer for Centering Animation */
.spacer {
    flex-grow: 1;
    transition: flex-grow 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.spacer.collapsed {
    flex-grow: 0.0001; /* Not 0 to avoid layout glitches sometimes, but 0 is usually fine with flex */
    flex-grow: 0;
}

/* Filters Panel - Styled like Mode Toggle */
.filters-row {
    pointer-events: auto;
    background: #f3f4f6;
    padding: 0.25rem;
    border-radius: 9999px;
    border: 1px solid #e5e7eb;
    display: flex;
    gap: 0.5rem;
    align-items: center;
    /* Animation props */
    width: 0;
    opacity: 0;
    overflow: hidden;
    white-space: nowrap;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.filters-row.active {
    width: auto; /* Animate max-width ideally, but auto works with flex sometimes if handled well. Better: set max-width */
    opacity: 1;
    padding: 0.25rem 0.5rem; /* Restore padding */
}

.filter-select {
    appearance: none;
    -webkit-appearance: none;
    background: transparent;
    border: none;
    font-family: inherit;
    font-size: 0.9rem;
    color: var(--text-gray);
    padding: 0.25rem 1rem;
    border-radius: 9999px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}

.filter-select:hover {
    background: white;
    color: var(--text-dark);
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.filter-select:focus {
    outline: none;
    color: var(--primary);
}



/* App Layout */
.app-container {
    display: flex;
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
    gap: 2rem;
    min-height: 80vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    flex-shrink: 0;
    height: fit-content;
    position: sticky;
    top: 180px; /* Offset */
}

.brand-list-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: white;
    border-bottom: 1px solid #f3f4f6;
    cursor: pointer;
    transition: var(--transition);
}
.brand-list-item:first-child { border-top-left-radius: 0.5rem; border-top-right-radius: 0.5rem; }
.brand-list-item:last-child { border-bottom-left-radius: 0.5rem; border-bottom-right-radius: 0.5rem; border-bottom: none; }

.brand-list-item:hover { background: #fff7ed; padding-left: 1.25rem; }
.brand-list-item.active { background: #fff7ed; color: var(--primary); font-weight: 600; border-left: 3px solid var(--primary); }

.brand-icon-sm {
    width: 24px;
    height: 24px;
    object-fit: contain;
}

/* Main Content */
.main-content {
    flex-grow: 1;
}

/* Boiler Tiles (Hardcoded style) */
.grid-boilers {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1.5rem;
}

.boiler-card {
    background: white;
    border-radius: 0.75rem;
    padding: 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid transparent;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.boiler-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1);
    border-color: var(--primary);
}

.boiler-card-icon {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    color: var(--primary);
}

/* Product Grid */
.grid-products {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1.5rem;
}

.product-card {
    background: white;
    border-radius: 0.75rem;
    overflow: hidden;
    border: 1px solid #e5e7eb;
    display: flex;
    flex-direction: column;
    transition: var(--transition);
    position: relative;
}

.product-card:hover {
    box-shadow: 0 10px 20px -5px rgba(0,0,0,0.1);
    border-color: var(--primary);
}

.product-img {
    height: 200px;
    padding: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
}
.product-img img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.product-body {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    border-top: 1px solid #f3f4f6;
}

.product-title {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
    line-height: 1.4;
    height: 2.8em;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.product-meta {
    font-size: 0.8rem;
    color: #9ca3af;
    margin-bottom: 1rem;
}

.product-footer {
    padding: 0.5rem 1rem 1rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.price-tag {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text-dark);
}

.add-btn {
    background: white;
    border: 2px solid var(--primary);
    color: var(--primary);
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}
.add-btn:hover {
    background: var(--primary);
    color: white;
}

.add-btn:active {
    transform: scale(0.95);
}

/* Animations */
@keyframes pop {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

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

.anim-pop { animation: pop 0.3s ease; }
.anim-slide-in { animation: slideInRight 0.3s ease forwards; }


/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    backdrop-filter: blur(4px);
}

.modal-content {
    background: white;
    width: 100%;
    max-width: 500px;
    height: 100%;
    position: absolute;
    right: 0;
    top: 0;
    padding: 2rem;
    box-shadow: -10px 0 25px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
}

/* Load More */
.load-more-btn {
    display: block;
    margin: 2rem auto;
    padding: 1rem 3rem;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 2rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}
.load-more-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

/* Footer */
footer {
    background: #111827;
    color: #e5e7eb;
    padding: 4rem 2rem;
    margin-top: auto;
    font-size: 0.95rem;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 3rem;
}

.footer-col h4 {
    color: white;
    margin-bottom: 1.5rem;
    font-size: 1.1rem;
    font-weight: 600;
}

.footer-col ul li { margin-bottom: 0.8rem; }
.footer-col a { color: #9ca3af; transition: color 0.2s; }
.footer-col a:hover { color: white; }

.contact-block { margin-bottom: 1.5rem; }
.contact-phone { font-size: 1.1rem; font-weight: bold; display: block; margin-bottom: 0.5rem; color: white; }
.social-footer { display: flex; gap: 1rem; margin-top: 1rem; }

/* Mobile Responsiveness */
@media (max-width: 768px) {
    /* Sticky Header Logic for Mobile */
    .sticky-container {
        position: sticky;
        top: 0;
    }

    /* Stack Header */
    .main-header {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
    }
    
    .logo {
        width: 100%;
        justify-content: center;
        order: 1;
    }
    
    .search-bar {
        width: 100%;
        order: 2;
        max-width: none;
    }
    
    .header-actions {
        width: 100%;
        justify-content: space-between;
        order: 3;
    }

    /* Sub Header & Toggle */
    .sub-header {
        flex-wrap: wrap;
        padding: 0.5rem 1rem;
        gap: 0.5rem;
    }
    
    .mode-toggle {
        width: 100%;
        display: flex;
    }
    
    .filters-row {
        max-width: 100%;
        overflow-x: auto;
        padding-bottom: 0.25rem; /* Space for scrollbar if any */
    }

    /* Layout */
    .app-container {
        display: flex;
        flex-direction: column;
        padding: 1rem;
    }

    /* Horizontal Rolling Sidebar */
    .sidebar {
        width: 100%;
        top: 70px; /* Below sticky header approx */
        z-index: 900;
        background: var(--bg-light);
        margin-bottom: 1rem;
        border-right: none;
        border-bottom: 1px solid #e5e7eb;
        
        /* Flex Row */
        display: flex;
        flex-direction: row;
        overflow-x: auto;
        white-space: nowrap;
        gap: 0.5rem;
        padding-bottom: 0.5rem;
    }

    .brand-list-item {
        flex: 0 0 auto;
        border: 1px solid #e5e7eb;
        border-radius: 2rem;
        padding: 0.5rem 1rem;
        background: white;
    }
    
    .brand-list-item:hover {
        background: #fff7ed;
    }
    
    .brand-list-item h3 {
        display: none; /* Hide 'Бренды' title if inside sidebar? Title is h3 before div. */
    }
    
    /* Hide the title 'Бренды' specifically */
    .sidebar h3 {
        display: none;
    }

    #sidebarContent {
        display: flex;
        gap: 0.5rem;
    }

    /* Grid layout */
    .grid-boilers, .grid-products {
        grid-template-columns: repeat(2, 1fr); /* 2 cols on mobile */
        gap: 0.5rem;
    }
    
    .product-img {
        height: 140px;
    }
    
    .product-title {
        font-size: 0.9rem;
    }
    
    .price-tag {
        font-size: 1.1rem;
    }
    
    /* Modal */
    .modal-content {
        max-width: 100%;
    }
}

