:root {
    --primary-blue: #304296;
    --dark-gray: #3E4146;
    --background-gray: #F5F5F5;
    --accent-color: #304296;
    --white: #FFFFFF;
    --font-header: 'Montserrat', sans-serif;
    --font-body: 'Roboto', sans-serif;
}
* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
    font-family: var(--font-body), sans-serif;
    background-color: var(--background-gray);
    color: var(--dark-gray);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
}

main {
    flex-grow: 1;
    padding: 30px 0;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

h1, h2, h3, h4 {
    font-family: var(--font-header), sans-serif;
    color: var(--primary-blue);
    margin-bottom: 0.5em;
}

.cta-button {
    background-color: var(--accent-color);
    color: var(--white);
    border: none;
    padding: 10px 20px;
    font-family: var(--font-body), sans-serif;
    font-weight: 500;
    font-size: 16px;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.cta-button:hover {
    background-color: #243377;
}

header {
    background-color: var(--white);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.top-bar {
    background-color: var(--background-gray);
    padding: 10px 0;
}

.top-bar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo img {
    max-height: 50px;
    display: block;
}

.top-bar .phone {
    font-size: 22px;
    font-weight: 600;
    color: var(--dark-gray);
    text-decoration: none;
    transition: color 0.3s ease;
}
.top-bar .phone:hover {
    color: var(--primary-blue);
}

.bottom-bar {
    background-color: var(--white);
    padding: 15px 0;
    border-bottom: 1px solid #ddd;
}

nav {
    display: block;
}

nav a {
    color: var(--dark-gray);
    text-decoration: none;
    margin-right: 25px;
    font-weight: 500;
    font-size: 16px;
}

nav a:last-child {
    margin-right: 0;
}

nav a:hover {
    color: var(--primary-blue);
}

.header-contacts { display: none; }

.search-section {
    background-color: var(--white);
    padding: 30px;
    border-radius: 5px;
    margin-bottom: 30px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.search-result-text {
    font-size: 1.2em;
    margin-bottom: 20px;
    background-color: #eef;
    padding: 10px;
    border-radius: 5px;
    grid-column: 1 / -1;
}
.catalog-layout { display: flex; gap: 30px; align-items: flex-start; }
.filter-group { margin-bottom: 20px; }
.filter-group label { display: block; font-weight: 500; margin-bottom: 8px; }
.filter-group select, .filter-group input { width: 100%; padding: 8px; border: 1px solid #ddd; border-radius: 3px;}

/* Контейнер для всех фильтров */
.filters {
    background-color: var(--white);
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 30px;
    border: 1px solid #E0E0E0;
}

.filters form {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: center;
}

.filters select {
    padding: 10px 35px 10px 15px;
    font-size: 15px;
    font-family: var(--font-body), sans-serif;
    border: 1px solid #ccc;
    border-radius: 5px;
    background-color: #f9f9f9;
    cursor: pointer;
    flex-grow: 1;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23304296'%3E%3Cpath d='M6 9L.5 3h11L6 9z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 15px center;
}

.filters select:hover {
    border-color: #aaa;
}

.filters .reset-button {
    background-color: #6c757d;
    color: white;
    padding: 7px 20px;
    text-decoration: none;
    border-radius: 5px;
    font-size: 15px;
    font-weight: 500;
    transition: background-color 0.2s;
    border: none;
}

.filters .reset-button:hover {
    background-color: #5a6268;
}

/* --- Стили для пагинации --- */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 40px;
    gap: 8px;
}

.pagination a,
.pagination .current-page {
    display: inline-block;
    min-width: 40px;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 5px;
    text-align: center;
    text-decoration: none;
    font-size: 15px;
    font-weight: 500;
    font-family: var(--font-header), sans-serif;
    transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}

.pagination a {
    background-color: var(--white);
    color: var(--primary-blue);
}

.pagination a:hover {
    background-color: #f7f7f7;
    border-color: #ccc;
}

.pagination .current-page {
    background-color: var(--primary-blue);
    color: var(--white);
    border-color: var(--primary-blue);
    cursor: default;
}

/* Отступ для верхнего блока пагинации */
.pagination.pagination-top {
    margin-bottom: 40px;
}

/* --- Стили для блока фильтров --- */
.filters form {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: flex-end;
}

.filter-item {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-width: 150px;
}

.filter-item label {
    font-size: 13px;
    font-weight: 500;
    color: #555;
    margin-bottom: 4px;
    padding-left: 2px;
}

/* --- Стили для окна поиска --- */
.search-bar {
    position: relative;
    flex-grow: 2;
    margin-bottom: 15px;
}

.search-bar input {
    width: 100%;
    padding: 10px 35px 10px 15px;
    border: 1px solid #ccc;
    border-radius: 5px;
}

.search-bar button {
    position: absolute;
    right: 0;
    top: 0;
    height: 100%;
    width: 40px;
    background: none;
    border: none;
    color: #777;
    cursor: pointer;
    font-size: 16px;
    padding: 0;
    transition: color 0.2s;
}

.search-bar button:hover {
    color: var(--primary-blue);
}

/* --- Стили для основного каталога --- */
.products-grid {
    display: grid;
    /* По умолчанию одна колонка (для мобильных устройств) */
    grid-template-columns: 1fr;
    gap: 10px;
}

/* Для экранов шире 768px (планшеты и ПК) делаем две колонки */
@media (min-width: 768px) {
    .products-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.product-card { background-color: var(--white); border: 1px solid #eee; height: 100%; border-radius: 5px; padding: 20px; display: flex; flex-direction: column; transition: box-shadow 0.3s; cursor: pointer; }
.product-card:hover { box-shadow: 0 4px 15px rgba(0,0,0,0.1); }
.product-card img { max-width: 100%; height: auto; margin: 5px; border-radius: 3px; }
.product-card h4 { margin-bottom: 10px; font-size: 18px; flex-grow: 1; }
.product-card .price { font-size: 18px; font-weight: 700; color: var(--dark-gray); margin-bottom: 15px; }

.product-card .product-details {
    margin: 12px 0;
    font-size: 14px;
    color: #555;
    text-align: left;
    border-top: 1px solid #eee;
    padding-top: 12px;
}

.product-card .product-details p {
    margin-bottom: 6px;
    line-height: 1.4;
}

.product-card .product-details p:last-child {
    margin-bottom: 0;
}

.product-card .product-details strong {
    color: var(--dark-gray);
    margin-right: 5px;
    font-weight: 500;
}

.text-page { background: #fff; border-radius: 5px; padding: 20px 30px 40px; }
.text-page h3 { margin-top: 1.5em; }
.text-page ul, .text-page ol { margin-left: 20px; margin-bottom: 1em; }
.text-page p { margin-bottom: 1em; }

.text-page a {
    color: var(--primary-blue);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: color 0.3s, border-bottom 0.3s;
}

.text-page a:hover {
    color: var(--dark-gray);
    border-bottom: 1px solid var(--dark-gray);
}

/* Контейнер для контента карточки товара */
.product-main-content {
    display: flex;
    align-items: center;
    gap: 20px;
    margin: 15px 0;
    flex-grow: 1;
}

/* Левая часть - характеристики */
.product-details {
    flex: 1;
    text-align: left;

    min-width: 0;
    overflow-wrap: break-word;
}

/* Правая часть - контейнер фото */
.product-image-container {
    max-width: 50%;
    flex-shrink: 0;
    height: auto;
    margin-bottom: 0;
    background-color: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 5px;
}

/* Сама фотография */
.product-image-container img {
    width: auto;
    max-width: 100%;
    height: auto;
    max-height: 200px;
    object-fit: contain;
    background-color: #fff;
    border: 1px solid #eee;
    padding: 3px;
}

/* --- Стили для подвала --- */
footer {
    padding: 40px 0;
    background-color: var(--dark-gray);
    color: #ccc;
    margin-top: 40px;
    font-size: 14px;
}
footer .footer-content {
    display: flex;
    justify-content: space-between;
    gap: 30px;
    margin-bottom: 30px;
    text-align: center;
}
footer .footer-column {
    flex: 1;
}
footer h4 {
    color: var(--white);
    margin-bottom: 15px;
    font-size: 16px;
}
footer p, footer ul {
    list-style: none;
    padding: 0;
    margin: 0;
    line-height: 1.8;
}
footer a {
    color: #ccc;
    text-decoration: none;
    transition: color 0.3s;
}
footer a:hover {
    color: var(--white);
}
.footer-bottom {
    text-align: center;
    border-top: 1px solid #555;
    padding-top: 20px;
    font-size: 13px;
}
.footer-bottom a {
    margin: 0 10px;
}

/* Общий стиль для обеих плавающих кнопок */
.back-to-top, .whatsapp-widget {
    position: fixed;
    right: 20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    text-decoration: none;
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
    transition: all 0.3s ease;
    z-index: 4000;
}

.back-to-top:hover, .whatsapp-widget:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 12px rgba(0,0,0,0.2);
}

/* Кнопка "Наверх" */
.back-to-top {
    bottom: 85px;
    background-color: var(--primary-blue);
    /* По умолчанию скрыта */
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
}

/* Класс для показа кнопки "Наверх" через JS */
.back-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Виджет WhatsApp */
.whatsapp-widget {
    bottom: 20px; /* Располагаем над кнопкой "Наверх" */
    background-color: #25D366; /* Фирменный цвет WhatsApp */
}

/* --- Стили для кнопок соцсетей на странице контактов --- */
.social-buttons { list-style: none; padding: 0; margin-top: 20px; display: flex; flex-wrap: wrap; gap: 15px; }
.social-buttons a {
    flex-grow: 1;
    min-width: 120px;
    text-align: center;
    padding: 12px 15px;
    text-decoration: none;
    border: 1px solid var(--dark-gray);
    color: var(--dark-gray);
    border-radius: 5px;
    transition: background-color 0.3s, color 0.3s, border-color 0.3s;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.social-buttons a:hover {
    background-color: var(--dark-gray);
    color: var(--white);
    border-color: var(--dark-gray);
}
.social-buttons a i {
    font-size: 18px;
}

/* --- Стили для модального окна --- */
.modal { display: none; position: fixed; z-index: 2000; left: 0; top: 0; width: 100%; height: 100%; overflow: auto; background-color: rgba(0,0,0,0.5); justify-content: center; align-items: center; }
.modal.is-visible { display: flex; }

.modal-content { background-color: #fff; padding: 30px; border-radius: 5px; width: 90%; max-width: 500px; position: relative; animation: fadeIn 0.3s; text-align: center; }

.close-button { color: #aaa; float: right; font-size: 28px; font-weight: bold; position: absolute; top: 10px; right: 20px; cursor: pointer; }
.close-button:hover, .close-button:focus { color: black; }

.modal-content h3 { margin-bottom: 15px; }
.modal-content p { margin-bottom: 20px; }

.modal-content .modal-phone { display: block; font-size: 22px; font-weight: 700; color: var(--primary-blue); margin-bottom: 20px; }

@keyframes fadeIn { from {opacity: 0; transform: scale(0.9);} to {opacity: 1; transform: scale(1);} }

/* --- Стили для соцсетей в модальном окне и подвале --- */
.social-links { list-style: none; padding: 0; margin: 10px 0 0 0; display: flex; gap: 15px; justify-content: center; }
.social-links a { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 50%; background-color: var(--primary-blue); color: var(--white); font-size: 18px; transition: background-color 0.3s, transform 0.2s; }
.social-links a:hover { background-color: var(--dark-gray); transform: scale(1.1); }
#contactModal {
    z-index: 2001;
}

/* --- Стили для модального окна с картой --- */
.modal-map-content {
    padding: 10px;
    background-color: #fff;
    border-radius: 5px;
    width: 95%;
    max-width: 600px;
    position: relative;
}

.modal-map-image {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 3px;
}

footer .map-link {
    border: none;
    padding: 0;
    vertical-align: baseline;
    background: none;
}
footer .map-link:hover {
    color: var(--white);
    background: none;
}

/* --- Стили для модального окна с деталями товара --- */
.modal-product-content {
    background-color: #fff;
    padding: 30px;
    border-radius: 5px;
    width: 90%;
    max-width: 800px;
    position: relative;
    animation: fadeIn 0.3s;
    text-align: left;
    max-height: 90vh;
    overflow-y: auto;
}

.product-detail-layout {
    display: flex;
    gap: 30px;
}

.product-detail-gallery {
    flex-basis: 45%;
}

.product-detail-gallery .main-photo img {
    width: 100%;
    border-radius: 5px;
    border: 1px solid #eee;
    margin-bottom: 10px;
}

.product-detail-gallery .thumbnail-photos {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.product-detail-gallery .thumbnail-photos img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 4px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: border-color 0.2s;
}

.product-detail-gallery .thumbnail-photos img:hover,
.product-detail-gallery .thumbnail-photos img.active {
    border-color: var(--primary-blue);
}

.product-detail-info {
    flex-basis: 55%;
}

.product-detail-info h2 {
    margin-top: 0;
    border-bottom: 2px solid var(--primary-blue);
    padding-bottom: 10px;
    margin-bottom: 15px;
}

.product-detail-info table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}

.product-detail-info table td {
    padding: 8px 3px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 15px;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
}

.product-detail-info table tr:last-child td {
    border-bottom: none;
}

.product-detail-info table td strong {
    color: var(--dark-gray);
}

.product-detail-price {
    font-size: 28px;
    font-weight: 700;
    color: var(--dark-gray);
    margin-bottom: 20px;
}

.modal-loader {
    width: 100%;
    text-align: center;
    padding: 50px 0;
    font-size: 18px;
}

@media (max-width: 768px) {
    .product-detail-layout {
        flex-direction: column;
    }
}

::selection { background-color: var(--accent-color); color: var(--white); }
::-moz-selection { background-color: var(--accent-color); color: var(--white); }

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--background-gray); }
::-webkit-scrollbar-thumb { background-color: var(--primary-blue); border-radius: 0; }
::-webkit-scrollbar-thumb:hover { background-color: var(--dark-gray); }
html { scrollbar-width: thin; scrollbar-color: var(--primary-blue) var(--background-gray); }

/* Адаптация */
.hamburger-menu { display: none; }
.mobile-nav { display: none; }

@media (max-width: 992px) {
    .container { padding: 0 15px; }
    .text-page { padding: 15px 15px; }
    .filters { flex-basis: 200px; }
    .product-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
    .bottom-bar .container { justify-content: space-between; align-items: center; }
    footer .footer-content { flex-direction: column; }
}
@media (max-width: 768px) {
    .bottom-bar nav { display: none; }
    .hamburger-menu { display: block; cursor: pointer; }
    .logo img { max-height: 40px; }
    .top-bar .phone { font-size: 14px; }
    .mobile-nav { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.9); z-index: 3000; flex-direction: column; justify-content: center; align-items: center; opacity: 0; transition: opacity 0.3s ease-in-out; }
    .mobile-nav.open { display: flex; opacity: 1; }
    .mobile-nav a { color: var(--white); text-decoration: none; font-size: 24px; margin: 15px 0; font-family: var(--font-header), sans-serif; }
    .close-menu-btn { position: absolute; top: 20px; right: 20px; color: var(--white); font-size: 40px; cursor: pointer; }
    main { padding: 20px 0; }
    h1 { font-size: 28px; }
    .search-bar { flex-direction: column; }
    .search-bar button { border-radius: 0 0 5px 5px; }
    .catalog-layout { flex-direction: column; }
    .filters { position: static; width: 100%; margin-bottom: 20px; }
    footer .footer-bottom div { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
    .social-buttons { justify-content: stretch; }
    .social-buttons a { width: 100%; }
    .close-button { top: 0; right: 10px; }
}