/* css/product-page.css */

/* ==========================================================================
   1. Основные настройки страницы
   ========================================================================== */
   body.product-page {
    background-color: var(--color-background-main);
}

/* ==========================================================================
   2. Шапка страницы товара
   ========================================================================== */
.site-header {
    background-color: var(--color-background-dark-hero);
    padding: 10px 0;
    box-shadow: var(--shadow-light);
    transition: box-shadow 0.3s ease;
    position: relative;
    z-index: var(--z-index-sticky);
    width: 100%;
}

.site-header.is-sticky {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    box-shadow: var(--shadow-dark);
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from { transform: translateY(-100%); }
    to { transform: translateY(0); }
}

.main-nav-product {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px; /* Зазор между лого и кнопками */
}

.main-nav-product .logo-link {
    flex-shrink: 0; /* Логотип не сжимается */
}

.main-nav-product .logo-link img {
    height: 32px; /* Уменьшаем для мобильных по умолчанию */
    width: auto;
    display: block;
}

/* Группа кнопок справа */
.header-actions {
    display: flex;
    align-items: center;
    gap: 8px; /* Уменьшенный отступ для мобильных */
}

/* Кнопка "Каталог" */
.main-nav-product .nav-link {
    color: var(--color-accent-gold);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    height: 36px; 
    padding: 0 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--color-accent-gold);
    border-radius: var(--border-radius-medium);
    transition: all 0.2s ease;
    white-space: nowrap;
    background: transparent;
    cursor: pointer;
}

/* ОБНОВЛЕНИЕ: Унификация кнопок "Связь" (трубка) и "Корзина" */
.contact-toggle-btn-header,
#cart-toggle-btn {
    width: 36px;
    height: 36px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--color-accent-gold); /* Явная рамка для единообразия */
    border-radius: var(--border-radius-medium);
    background: transparent;
    color: var(--color-accent-gold);
    cursor: pointer;
    position: relative; /* Для бейджа корзины */
    box-sizing: border-box; /* Чтобы padding и border входили в размер */
}

/* Унификация размера иконок внутри кнопок */
.contact-toggle-btn-header i,
.contact-toggle-btn-header .filter-icon-wrapper,
#cart-toggle-btn i {
    font-size: 1.1rem; /* Фиксированный размер иконки */
    display: flex;
    align-items: center;
    justify-content: center;
}
/* Обертка иконки внутри кнопки контактов */
.contact-toggle-btn-header .filter-icon-wrapper {
    width: 100%;
    height: 100%;
}


/* Панель контактов (выпадающая) */
.contact-content-panel-product {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background-color: var(--color-background-dark-hero);
    box-shadow: inset 0 5px 10px -5px rgba(0,0,0,0.3);
    z-index: -1;
    padding: 15px;
}
.site-header.contact-panel-open .contact-content-panel-product {
    display: block;
}

/* Адаптация шапки под большие экраны */
@media (min-width: 768px) {
    .site-header { padding: 15px 0; }
    .main-nav-product .logo-link img { height: 40px; }
    .header-actions { gap: 15px; }
    
    .main-nav-product .nav-link {
        height: 42px;
        padding: 0 20px;
        font-size: 1rem;
    }
    
    /* Увеличиваем кнопки на планшетах/десктопах */
    .contact-toggle-btn-header,
    #cart-toggle-btn {
        width: 42px;
        height: 42px;
    }
    .contact-toggle-btn-header i,
    .contact-toggle-btn-header .filter-icon-wrapper,
    #cart-toggle-btn i {
        font-size: 1.3rem; 
    }
}

/* Адаптация под 320px (iPhone SE 1st gen, малые Android) */
@media (max-width: 359.98px) {
    .main-nav-product .logo-link img { height: 28px; }
    .header-actions { gap: 5px; }
    .main-nav-product .nav-link { 
        padding: 0 8px; 
        font-size: 0.8rem; 
        height: 34px; 
    }
    .contact-toggle-btn-header,
    #cart-toggle-btn { 
        width: 34px; 
        height: 34px; 
    }
}

/* ОБНОВЛЕНИЕ: Скрытие логотипа для ширины < 380px (чуть агрессивнее, чем 360, для надежности) */
@media (max-width: 380px) {
    .main-nav-product .logo-link {
        display: none; /* Скрываем логотип */
    }
    
    .main-nav-product {
        justify-content: flex-end; /* Сдвигаем все вправо (или можно space-around если нужно) */
    }
    
    /* Растягиваем блок кнопок на всю ширину для удобства */
    .header-actions {
        width: 100%;
        justify-content: space-between;
        gap: 10px;
    }
    
    .main-nav-product .nav-link {
        flex-grow: 1; /* Кнопка "Разделы" занимает доступное место */
    }
}


/* ==========================================================================
   3. Основной контейнер товара
   ========================================================================== */
.product-container {
    background-color: var(--color-background-card);
    padding: 15px; /* Уменьшено для мобильных */
    margin: 20px 0;
    border-radius: var(--border-radius-large);
    box-shadow: var(--shadow-medium);
}

.breadcrumbs {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--color-border-light);
    line-height: 1.4;
}

.breadcrumbs a {
    color: var(--color-text-dark);
    text-decoration: none;
    font-weight: 500;
}
.breadcrumbs span { color: #999; }

.product-layout {
    display: flex;
    flex-direction: column; /* Mobile First: колонка */
    gap: 30px;
}

/* ==========================================================================
   4. Галерея
   ========================================================================== */
.product-gallery-container {
    display: flex;
    flex-direction: column;
    width: 100%;
}

.main-image-wrapper {
    width: 100%;
    border: 1px solid var(--color-border-light);
    border-radius: var(--border-radius-medium);
    margin-bottom: 10px;
    padding: 5px;
    background-color: #fff;
    position: relative;
    /* Соотношение сторон квадрата, чтобы не прыгало при загрузке */
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

#main-product-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    cursor: zoom-in;
}

/* Кнопки навигации по слайдеру */
.main-image-wrapper .slider-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    background-color: rgba(255, 255, 255, 0.7);
    color: var(--color-text-dark);
    border: 1px solid rgba(0,0,0,0.1);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 24px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    /* Улучшение для тача */
    opacity: 0.8; 
}

.main-image-wrapper .slider-nav-btn:active {
    background-color: var(--color-accent-gold);
    opacity: 1;
}

.main-image-wrapper .slider-nav-btn.prev { left: 10px; }
.main-image-wrapper .slider-nav-btn.next { right: 10px; }
.main-image-wrapper .slider-nav-btn:disabled {
    opacity: 0.2;
    cursor: not-allowed;
}

/* Скроллер миниатюр */
.thumbnail-scroller {
    width: 100%;
    overflow-x: auto;
    padding-bottom: 5px;
    -webkit-overflow-scrolling: touch; /* Плавный скролл на iOS */
    scrollbar-width: none; /* Firefox: скрыть скроллбар */
}
.thumbnail-scroller::-webkit-scrollbar { display: none; /* Chrome/Safari: скрыть */ }

.thumbnails {
    display: flex;
    flex-wrap: nowrap;
    gap: 10px;
}

.thumbnails img {
    width: 64px;
    height: 64px;
    border: 2px solid var(--color-border-medium);
    border-radius: var(--border-radius-small);
    cursor: pointer;
    object-fit: cover;
    flex-shrink: 0;
    transition: border-color 0.2s;
}

.thumbnails img.active {
    border-color: var(--color-primary);
}

/* ==========================================================================
   5. Информация о товаре
   ========================================================================== */
.product-details-container {
    display: flex;
    flex-direction: column;
}

#product-title {
    font-size: clamp(1.4rem, 6vw, 2.2rem);
    font-weight: 700;
    color: var(--color-text-heading);
    margin-bottom: 15px;
    line-height: 1.2;
}

/* Блок цены */
.product-price-new-wrapper {
    margin-bottom: 15px;
}

.product-price-new {
    display: flex;
    align-items: baseline;
    gap: 15px;
    flex-wrap: wrap;
    margin-bottom: 5px;
}

.old-price {
    font-size: 1.2rem;
    color: var(--color-text-muted);
    text-decoration: line-through;
    font-weight: 500;
}

.current-price {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--color-text-heading);
}

.installment-info {
    font-size: 0.95rem;
    font-weight: 600;
    color: #555;
    background-color: #f0f0f0;
    padding: 4px 8px;
    border-radius: 4px;
    display: inline-block;
}

.product-availability {
    font-weight: 600;
    color: #28a745;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.product-availability::before {
    content: '';
    display: block;
    width: 8px;
    height: 8px;
    background-color: #28a745;
    border-radius: 50%;
}

/* Действия */
.product-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 30px;
}

.product-actions .action-btn {
    width: 100%;
    padding: 14px;
    border-radius: var(--border-radius-medium);
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border: none;
    background-color: var(--color-primary);
    color: var(--color-text-dark-hero);
    transition: transform 0.1s;
}

.product-actions .action-btn:active {
    transform: scale(0.98);
}

/* ==========================================================================
   6. Табы и Контент
   ========================================================================== */
.product-info-tabs {
    margin-top: 10px;
}

/* Скроллируемые табы для мобильных */
.product-info-tabs .tab-buttons {
    display: flex;
    border-bottom: 1px solid var(--color-border-medium);
    margin-bottom: 20px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
}
/* Скрываем скроллбар */
.product-info-tabs .tab-buttons::-webkit-scrollbar { display: none; }

.product-info-tabs .tab-btn {
    padding: 12px 16px;
    cursor: pointer;
    border: none;
    background: none;
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-text-muted);
    border-bottom: 3px solid transparent;
    margin-bottom: -1px;
    flex-shrink: 0; /* Чтобы не сжимались */
    transition: color 0.2s;
}

.product-info-tabs .tab-btn.active {
    color: var(--color-text-heading);
    border-bottom-color: var(--color-primary);
}

.tab-content {
    display: none;
    line-height: 1.6;
    font-size: 0.95rem;
}
.tab-content.active {
    display: block;
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Таблица характеристик */
.spec-table {
    width: 100%;
    border-collapse: collapse;
}

.spec-table td {
    padding: 10px 0;
    border-bottom: 1px solid var(--color-border-extralight);
    vertical-align: top;
}

.spec-table tr:last-child td { border-bottom: none; }

.spec-table td:first-child {
    color: var(--color-text-medium);
    width: 50%;
    padding-right: 10px;
}
.spec-table td:last-child {
    font-weight: 500;
    color: var(--color-text-dark);
}

/* Описание и списки */
.rich-description ul {
    list-style: none;
    padding-left: 0;
    margin: 15px 0;
}

.rich-description ul li {
    padding-left: 20px;
    position: relative;
    margin-bottom: 8px;
}

.rich-description ul li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 8px;
    width: 6px;
    height: 6px;
    background-color: var(--color-primary);
    border-radius: 50%;
}

.use-cases-block, .whats-in-the-box-block, .why-buy-block {
    margin-top: 25px;
    padding-top: 15px;
    border-top: 1px dashed var(--color-border-medium);
}

.use-cases-item, .why-buy-item {
    background-color: var(--color-background-highlight);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 10px;
}

/* ==========================================================================
   7. Отзывы и Вопросы
   ========================================================================== */
.reviews-section, .qa-section {
    margin-top: 40px;
}

.reviews-section h2, .qa-section h2 {
    font-size: 1.4rem;
    margin-bottom: 20px;
}

.review-bubble {
    background-color: #fff;
    border: 1px solid #eee;
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 15px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.03);
}

.review-author { font-weight: 700; margin-bottom: 5px; }
.review-date { font-size: 0.8rem; color: #999; text-align: right; }

/* Аккордеон вопросов */
.qa-item {
    border: 1px solid var(--color-border-medium);
    border-radius: 8px;
    margin-bottom: 10px;
    overflow: hidden;
    background: #fff;
}

.qa-question {
    width: 100%;
    padding: 15px;
    background: none;
    border: none;
    text-align: left;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}

.qa-answer {
    padding: 0 15px 15px;
    color: #555;
    display: none; /* JS переключает */
}
/* JS logic for QA usually toggles a class or max-height */


/* ==========================================================================
   8. Media Queries (Планшеты и Десктопы)
   ========================================================================== */

/* Tablets (Portrait & Landscape) */
@media (min-width: 768px) {
    .product-container { padding: 30px; }
    
    .product-layout {
        flex-direction: row;
        align-items: flex-start;
        gap: 30px;
    }
    
    .product-gallery-container {
        flex: 1 1 45%;
        max-width: 45%;
        position: sticky;
        top: 80px; /* Учитываем высоту хедера */
    }
    
    .product-details-container {
        flex: 1 1 55%;
        max-width: 55%;
    }
    
    .product-actions {
        flex-direction: row;
        width: 100%;
    }
    
    .product-actions .action-btn {
        width: auto;
        min-width: 200px;
    }
    
    /* Контакты в шапке */
    .contact-actions {
        justify-content: center;
    }
    .contact-actions .btn-base {
        flex: 0 1 250px;
    }
}

/* Desktops */
@media (min-width: 992px) {
    .product-container { padding: 40px; }
    
    .product-gallery-container {
        flex: 1 1 40%;
        max-width: 40%;
    }
    .product-details-container {
        flex: 1 1 60%;
        max-width: 60%;
    }
    
    .header-actions { gap: 20px; }
}

/* FIX #5: Landscape-ориентация для страницы товара */
@media (max-height: 500px) and (orientation: landscape) {
    .product-layout {
        flex-direction: row;
        gap: 20px;
    }
    .product-gallery-container {
        flex: 1 1 40%;
        max-width: 40%;
        position: static;
    }
    .product-details-container {
        flex: 1 1 60%;
        max-width: 60%;
    }
    .product-actions {
        flex-direction: row;
        gap: 8px;
    }
    .product-actions .action-btn {
        width: auto;
        min-width: 150px;
        padding: 10px 16px;
    }
    .product-container {
        padding: 10px;
        margin: 10px 0;
    }
    .main-image-wrapper {
        aspect-ratio: 4 / 3;
    }
}