:root{
    --primary: #4f46e5;
    --primary-600: #4338ca;
    --muted: #94a3b8;
    --text: #1e293b;
    --bg: #ffffff;
    --card-radius: 16px;
    --gap-sm: 12px;
    --gap-md: 24px;
}

/* ==========================================================================
   СТОРІНКА ТОВАРУ (Single Product)
   ========================================================================== */

/* Page wrapper */
.product-wrapper{ padding-top:20px; max-width:1200px; margin:0 auto; box-sizing:border-box; }

/* Product layout grid */
.product-page-layout { display:grid; grid-template-columns: 1fr 1fr; gap:40px; align-items:start; width:100%; }

/* Блок інформації */
.info-side {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}

/* Блок зображення */
.main-img-box { position:relative; border-radius:20px; overflow:hidden; border:1px solid #e2e8f0; background:var(--bg); cursor:crosshair; aspect-ratio:3/4; display:flex; align-items:center; justify-content:center; width:100%; }
.main-img-box img { width:100%; height:100%; object-fit:contain; display:block; background:var(--bg); }

.out-of-stock-label { position:absolute; background:rgba(0,0,0,0.7); color:#fff; padding:10px 20px; border-radius:30px; font-weight:bold; z-index:5; }

#zoomResult { position:absolute; inset:0; background-repeat:no-repeat; background-size:250%; display:none; pointer-events:none; z-index:10; background-color:var(--bg); }

/* Галерея мініатюр */
.thumbnails-grid { display:flex; gap:10px; margin-top:15px; flex-wrap:wrap; }
.thumb-item { width:60px; height:80px; border-radius:8px; cursor:pointer; border:2px solid transparent; overflow:hidden; transition:0.18s; flex-shrink:0; }
.thumb-item.active { border-color:var(--primary); }
.thumb-item img { width:100%; height:100%; object-fit:cover; display:block; }

/* Інфо-панель */
.meta-row { display:flex; justify-content:space-between; margin-bottom:15px; align-items:center; font-size:13px; color:var(--muted); }
.art-code { color:var(--muted); font-weight:600; }
.stock-badge { font-weight:700; }
.stock-badge.in-stock { color:#10b981; }
.stock-badge.out-of-stock { color:var(--muted); }

.product-title { font-size:28px; font-weight:800; color:var(--text); margin:0 0 20px; line-height:1.3; }

/* Ціна */
.price-container { margin-bottom:30px; }
.price-value { font-size:40px; font-weight:900; color:var(--primary); }
.price-currency { font-size:20px; color:var(--muted); margin-left:5px; font-weight:700; }

/* Кнопки */
.actions-container { display:flex; gap:12px; margin-bottom:20px; width:100%; }
.btn-buy-now { padding:18px; background:var(--primary); color:#fff; border:none; border-radius:12px; font-weight:800; font-size:16px; cursor:pointer; transition:0.22s; flex:2; min-width:0; max-width:300px; }
.btn-buy-now:hover:not(.disabled) { background:var(--primary-600); transform:translateY(-2px); box-shadow:0 6px 18px rgba(79,70,229,0.12); }
.btn-buy-now.disabled { background:#e2e8f0; color:var(--muted); cursor:not-allowed; }

.btn-ask-tg { flex:1; display:flex; align-items:center; justify-content:center; gap:8px; text-decoration:none; color:var(--text); border:2px solid #e2e8f0; border-radius:12px; font-weight:700; transition:0.18s; padding:18px; min-width:0; }
.btn-ask-tg:hover { background:#f8fafc; border-color:#cbd5e1; }

/* Опис */
.description-section h3 { 
    font-size: 20px; 
    border-bottom: 2px solid #f1f5f9; 
    padding-bottom: 10px; 
    margin-bottom: 15px; 
    color: var(--text); 
}

.description-text { 
    line-height: 1.7; 
    color: #475569; 
    font-family: 'Inter', sans-serif; 
    word-wrap: break-word; 
    overflow-wrap: break-word; 
}

/* Прибираємо стандартний відступ у першого тегу (наприклад, <h2> або <p>), 
   який приходить з редактора тексту */
.description-text > *:first-child {
    margin-top: 0;
}

/* Правильні відступи для елементів всередині опису */
.description-text p {
    margin-bottom: 12px;
}

.description-text ul, 
.description-text ol {
    margin-bottom: 15px;
    padding-left: 20px; /* Відступ для маркерів списку */
}

.description-text li {
    margin-bottom: 8px; /* Невеликий відступ між пунктами */
}

.description-text *:last-child {
    margin-bottom: 0; /* Прибираємо зайвий відступ у самого останнього елемента */
}

/* Shipping info box moved from inline styles */
.shipping-info-box{ margin-top:25px; padding:15px; background:#f9f9f9; border-radius:8px; border-left:4px solid #ddd; }

.btn-limit{ animation: btn-pulse 0.35s ease; }

/* ==========================================================================
   MOBILE ADAPTIVE (Product)
   ========================================================================== */

@media (max-width: 850px) {
    .product-wrapper { padding: 15px; }
    .product-page-layout { grid-template-columns: 1fr; gap: 30px; }
    .product-title { font-size: 22px; }
    .price-value { font-size: 32px; }
    .actions-container { flex-direction: column; }
    .btn-buy-now { 
        width: 100%; 
        padding: 16px;
        max-width: 100%;
        flex: unset;
    }
    .btn-ask-tg { 
        width: 100%; 
        padding: 16px;
    }
    .thumbnails-grid { gap: 8px; }
    .thumb-item { width: 50px; height: 70px; }
}

@media (max-width: 480px) {
    .product-wrapper { padding: 10px; }
    .breadcrumb-nav { font-size: 12px; margin-bottom: 15px; }
    .product-page-layout { gap: 20px; }
    .main-img-box { border-radius: 15px; }
    
    /* Відключаємо зум на малих екранах, щоб не заважав скролу */
    #zoomResult { display: none !important; }
    .main-img-box { cursor: default; }

    .product-title { font-size: 18px; margin: 0 0 15px; }
    .price-container { margin-bottom: 20px; }
    .price-value { font-size: 28px; }
    .price-currency { font-size: 16px; }
    .actions-container { gap: 10px; margin-bottom: 30px; }
    .btn-buy-now { padding: 14px; font-size: 14px; }
    .btn-ask-tg { padding: 14px; font-size: 14px; }
    .description-section h3 { font-size: 18px; }
    .description-text { font-size: 0.95rem; }
    .thumbnails-grid { gap: 6px; margin-top: 10px; }
    .thumb-item { width: 45px; height: 60px; }
    .meta-row { margin-bottom: 10px; flex-direction: row; justify-content: space-between; }
    .art-code { font-size: 11px; }
    .stock-badge { font-size: 11px; }
}
/* ==========================================================================
   БЛОК: ВИ НЕЩОДАВНО ПЕРЕГЛЯДАЛИ
   ========================================================================== */
.recently-viewed { padding:40px 15px; background:var(--bg); border-radius:20px; margin-top:50px; }
.recently-viewed .recently-title { font-size:24px; font-weight:800; color:var(--text); margin-bottom:25px; padding-left:5px; }

/* Сітка для карток */
.recently-viewed .product-grid { display:grid; grid-template-columns: repeat(auto-fill, minmax(180px,1fr)); gap:20px; }

/* Стилізація картки, щоб вона була як у каталозі */
.recently-viewed .product-card {
    background: var(--white);
    border-radius: 15px;
    padding: 12px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: 1px solid var(--border-color);
    text-decoration: none !important;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.recently-viewed .product-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--card-shadow);
    border-color: var(--primary);
}

.recently-viewed .product-card a {
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.recently-viewed .product-grid-img {
    width: 100%;
    aspect-ratio: 3/4;
    object-fit: cover;
    border-radius: 10px;
    margin-bottom: 12px;
}

.recently-viewed .product-info h4 {
    font-size: 14px;
    line-height: 1.4;
    color: var(--text-main);
    margin-bottom: 8px;
    font-weight: 600;
    /* Обмеження тексту двома рядками */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.recently-viewed .price {
    font-size: 16px;
    font-weight: 800;
    color: var(--primary);
    margin-top: auto; /* Ціна завжди внизу картки */
}

/* Адаптивність для мобільних пристроїв */
@media (max-width: 480px) {
    .recently-viewed .product-grid {
        grid-template-columns: repeat(2, 1fr); /* 2 колонки на мобільних */
        gap: 10px;
    }
    .recently-viewed h3 {
        font-size: 20px;
    }
    .recently-viewed .product-info h4 {
        font-size: 13px;
    }
}
/* Підказка про стан книги під фото */
.condition-hint-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-top: 10px;
    font-size: 12px;
    color: var(--muted);
    text-decoration: none;
    border-bottom: 1px dashed currentColor;
    transition: color 0.18s;
    width: fit-content;
}
.condition-hint-link:hover {
    color: var(--primary);
}