/* ============================================
   ДЕТАЛЬНАЯ СТРАНИЦА ТОВАРА
   ============================================ */

.product-layout {
    display: flex;
    gap: 40px;
    margin-bottom: 40px;
    flex-wrap: wrap;
}

.gallery-section {
    flex: 0 0 40%;
    min-width: 300px;
    position: sticky;
    top: 20px;
    align-self: flex-start;
}

.info-section {
    flex: 1;
    min-width: 300px;
}

/* ============================================
   ГАЛЕРЕЯ ИЗОБРАЖЕНИЙ
   ============================================ */
.main-image-container {
    background: #F8F9FA;
    border-radius: 12px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    aspect-ratio: 1 / 1;
    max-height: 500px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.main-image {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    transition: opacity 0.3s ease, transform 0.3s ease;
    cursor: pointer;
}

.thumbnails-container {
    position: relative;
    width: 100%;
    margin-top: 15px;
}

.thumbnails {
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    scroll-behavior: smooth;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding: 10px 35px;
}

.thumbnails::-webkit-scrollbar {
    display: none;
}

.thumbnails-wrapper {
    display: flex;
    gap: 12px;
    justify-content: flex-start;
}

.thumbnail {
    flex: 0 0 auto;
    width: 80px;
    height: 80px;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s ease;
    background: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.thumbnail:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.thumbnail.active {
    border-color: #E67E22;
    box-shadow: 0 0 0 2px rgba(230, 126, 34, 0.3);
}

.thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.thumb-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 64px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 10;
    font-size: 24px;
    font-weight: bold;
    opacity: 0.8;
}

.thumb-nav:hover {
    background: rgba(0, 0, 0, 0.9);
    opacity: 1;
    transform: translateY(-50%) scale(1.05);
}

.thumb-nav.prev {
    left: 0;
}

.thumb-nav.next {
    right: 0;
}

.thumb-nav.hidden {
    display: none;
}

/* ============================================
   БРЕНД
   ============================================ */
.brand {
    color: #7F8C8D;
    margin-bottom: 10px;
    font-size: 1.1rem;
}

/* ============================================
   ТАБЛИЦА СРАВНЕНИЯ ЦЕН
   ============================================ */
.price-comparison {
    margin: 30px 0;
    overflow-x: auto;
}

.price-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.price-table th,
.price-table td {
    border: 1px solid #ECF0F1;
    padding: 12px 15px;
    text-align: left;
}

.price-table th {
    background-color: #F8F9FA;
    font-weight: 600;
    color: #2C3E50;
}

.price-table .store-cell {
    font-weight: 600;
    background-color: #fafafa;
}

.price-table .current-price {
    font-size: 1.2rem;
    font-weight: bold;
    color: #27AE60;
}

.price-table .out-of-stock {
    color: #E74C3C;
    font-style: italic;
}

.price-table .last-checked {
    font-size: 0.85rem;
    color: #888;
}

.store-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: #F8F9FA;
    border-radius: 6px;
    transition: all 0.2s;
    color: #E67E22;
    text-decoration: none;
}

.store-link:hover {
    background: #ECF0F1;
    text-decoration: underline;
}

.btn-out-of-stock:hover {
    background: #C0392B !important;
}

.btn-in-stock:hover {
    background: #219A52 !important;
}

/* ============================================
   ИСТОРИЯ ЦЕН И ГРАФИК
   ============================================ */
.price-history-section {
    margin: 30px 0;
}

/* Стили для вкладок истории цен */
.price-history-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.history-tab {
    padding: 8px 20px;
    border: none;
    border-radius: 30px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: #ECF0F1;
    color: #2C3E50;
}

.history-tab.active {
    background: #E67E22 !important;
    color: white !important;
}

.history-tab:hover {
    background: #D5DBDB;
}

.price-chart-container {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    margin-bottom: 20px;
}

canvas {
    max-height: 400px;
    width: 100%;
}

.price-history-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.price-history-table th,
.price-history-table td {
    border: 1px solid #ECF0F1;
    padding: 8px 12px;
    text-align: left;
}

.price-history-table th {
    background-color: #F8F9FA;
}

/* ============================================
   КНОПКИ ПЕРИОДА
   ============================================ */
.period-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.period-btn {
    padding: 6px 14px;
    border: 1px solid #ddd;
    background: white;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.period-btn:hover {
    background: #e9ecef;
}

/* АКТИВНАЯ КНОПКА ПЕРИОДА - С ПРИОРИТЕТОМ */
.period-btn.active {
    background: #E67E22 !important;
    color: white !important;
    border-color: #E67E22 !important;
}

/* ============================================
   ХАРАКТЕРИСТИКИ
   ============================================ */
.characteristics-section {
    margin: 30px 0;
}

.characteristics-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.characteristics-table th,
.characteristics-table td {
    border: 1px solid #ECF0F1;
    padding: 10px 12px;
    text-align: left;
}

.characteristics-table th {
    width: 35%;
    background-color: #F8F9FA;
    font-weight: 600;
}

/* ============================================
   ВАРИАЦИИ ТОВАРА
   ============================================ */
.variations-section {
    margin: 20px 0 25px 0;
    padding: 16px 0;
    border-top: 1px solid #ECF0F1;
    border-bottom: 1px solid #ECF0F1;
}

.variations-section h3 {
    font-size: 14px;
    font-weight: 600;
    color: #7F8C8D;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.variation-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.variation-btn {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 18px;
    background: #F8F9FA;
    border: 1px solid #ECF0F1;
    border-radius: 10px;
    color: #2C3E50;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    min-width: 80px;
    cursor: pointer;
}

.variation-btn:hover {
    background: #E67E22;
    border-color: #E67E22;
    color: white;
    text-decoration: none;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(230, 126, 34, 0.3);
}

.variation-btn.active {
    background: #E67E22;
    border-color: #E67E22;
    color: white;
    box-shadow: 0 2px 8px rgba(230, 126, 34, 0.4);
}

.variation-price {
    font-size: 12px;
    font-weight: normal;
    margin-top: 4px;
    opacity: 0.8;
}

.variation-btn:hover .variation-price,
.variation-btn.active .variation-price {
    color: rgba(255, 255, 255, 0.9);
}

/* ============================================
   КНОПКИ ДЕЙСТВИЙ
   ============================================ */
.product-actions {
    margin: 15px 0;
    padding: 10px 0;
    border-top: 1px solid #ECF0F1;
    border-bottom: 1px solid #ECF0F1;
}

.action-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    color: #2C3E50;
    transition: all 0.2s;
}

.action-btn:hover {
    background: #F8F9FA;
    color: #E67E22;
}

.action-btn svg {
    transition: stroke 0.2s;
}

.action-btn:hover svg {
    stroke: #E67E22;
}

.action-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.action-btn.disabled:hover {
    background: none;
    color: #2C3E50;
}

.action-btn.saved-btn.active svg {
    fill: #E74C3C;
    stroke: #E74C3C;
}

.compare-btn svg {
    transition: transform 0.3s ease, stroke 0.2s ease;
}

.compare-btn.active svg {
    transform: rotate(360deg);
    stroke: white;
}

.compare-btn.active {
    background: #27AE60;
    color: white;
}

.compare-btn:hover {
    background: rgba(230, 126, 34, 0.1);
}

.saved-btn svg {
    transition: all 0.2s ease;
}

.saved-btn.active svg {
    fill: #E74C3C;
    stroke: #E74C3C;
}

/* ============================================
   ПЕРЕКЛЮЧАТЕЛИ МАГАЗИНОВ ДЛЯ ГАЛЕРЕИ
   ============================================ */
.shop-selector {
    display: flex;
    gap: 10px;
    margin: 15px 0;
    flex-wrap: wrap;
}

.shop-btn {
    background: #F8F9FA;
    border: 1px solid #ECF0F1;
    border-radius: 30px;
    padding: 6px 16px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.shop-btn:hover {
    background: #ECF0F1;
}

.shop-btn.active {
    background: #E67E22;
    border-color: #E67E22;
    color: white;
}

/* ============================================
   ПЕРЕОПРЕДЕЛЕНИЕ СТИЛЕЙ КНОПОК ИСТОРИИ И ПЕРИОДА
   ============================================ */

/* Сброс общих стилей для кнопок истории и периода */
.history-tab,
.history-tab:not(.logout-btn):not(.delete-task-btn):not(.clear-all-btn):not(.thumb-nav),
.period-btn,
.period-btn:not(.logout-btn):not(.delete-task-btn):not(.clear-all-btn):not(.thumb-nav) {
    background: #ECF0F1 !important;
    color: #2C3E50 !important;
    border: none !important;
    padding: 8px 16px !important;
    border-radius: 20px !important;
    font-size: 14px !important;
    font-weight: normal !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    box-shadow: none !important;
    text-transform: none !important;
    line-height: normal !important;
    margin: 0 !important;
}

/* Ховер для неактивных кнопок */
.history-tab:hover:not(.active):not(.logout-btn):not(.delete-task-btn):not(.clear-all-btn):not(.thumb-nav),
.period-btn:hover:not(.active):not(.logout-btn):not(.delete-task-btn):not(.clear-all-btn):not(.thumb-nav) {
    background: #D5DBDB !important;
    color: #2C3E50 !important;
    transform: none !important;
}

/* АКТИВНАЯ ВКЛАДКА МАГАЗИНА — ОРАНЖЕВЫЙ ФОН, БЕЛЫЙ ТЕКСТ */
.history-tab.active,
.history-tab.active:not(.logout-btn):not(.delete-task-btn):not(.clear-all-btn):not(.thumb-nav) {
    background: #E67E22 !important;
    color: white !important;
    border: none !important;
}

/* АКТИВНАЯ КНОПКА ПЕРИОДА — ОРАНЖЕВЫЙ ФОН, БЕЛЫЙ ТЕКСТ */
.period-btn.active,
.period-btn.active:not(.logout-btn):not(.delete-task-btn):not(.clear-all-btn):not(.thumb-nav) {
    background: #E67E22 !important;
    color: white !important;
    border: none !important;
}

/* Убираем все лишние псевдоэлементы */
.history-tab::before,
.history-tab::after,
.period-btn::before,
.period-btn::after {
    display: none !important;
}

/* ============================================
   АДАПТИВНОСТЬ
   ============================================ */
@media (max-width: 768px) {
    .product-layout {
        flex-direction: column;
    }
    
    .gallery-section {
        position: relative;
        top: 0;
        width: 100%;
    }
    
    .thumbnail {
        width: 60px;
        height: 60px;
    }
    
    .price-table th,
    .price-table td {
        padding: 8px 10px;
        font-size: 14px;
    }
    
    .price-table th, 
    .price-table td {
        padding: 8px 6px;
        font-size: 12px;
    }
    
    .store-link {
        padding: 2px 4px;
        font-size: 11px;
    }

    .variation-buttons {
        gap: 8px;
    }
    
    .variation-btn {
        padding: 6px 12px;
        font-size: 12px;
        min-width: 65px;
    }
    
    .variation-price {
        font-size: 10px;
    }
}