/* =========================================
   MixShop DZ - Premium Product Page Styles
   Enhanced UX/UI, Accessibility, and Animations
   Design tokens (:root) now live in shared.css.
========================================= */

/* Font Awesome is loaded from cdnjs and its own stylesheet doesn't set
   font-display, so the icon font blocks text paint until it loads.
   Re-declaring the same @font-face rules (same family/weight/style, same
   files) with font-display: swap overrides cdnjs's version and lets text
   render immediately, with icons swapping in once the font arrives. */
@font-face {
    font-family: "Font Awesome 6 Free";
    font-style: normal;
    font-weight: 900;
    font-display: swap;
    src: url("https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/webfonts/fa-solid-900.woff2") format("woff2");
}
@font-face {
    font-family: "Font Awesome 6 Free";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/webfonts/fa-regular-400.woff2") format("woff2");
}
@font-face {
    font-family: "Font Awesome 6 Brands";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/webfonts/fa-brands-400.woff2") format("woff2");
}

.container { max-width: 1100px; margin: 30px auto; padding: 0 var(--space-md); min-height: 50vh; }

/* Offline Banner */
.offline-banner {
    background: var(--danger); color: #fff; text-align: center; padding: var(--space-sm); font-weight: 700;
    font-size: 14px; position: sticky; top: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; gap: 8px;
}

/* Animations */
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(14px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInImg {
    from { opacity: 0.2; transform: scale(0.98); }
    to { opacity: 1; transform: scale(1); }
}

.fade-in-anim { animation: fadeInImg 0.3s ease-out forwards; }

.product-essential {
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: start;
    gap: var(--space-xl);
    background: var(--white);
    padding: var(--space-xl);
    border-radius: 24px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.05);
    border: 1px solid var(--border);
    animation: fadeUp .45s ease both;
}

body.dark-mode .product-essential { box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4); }

/* Gallery & Real Image Zoom */
.product-gallery-wrapper { display: flex; flex-direction: column; gap: 15px; min-width: 0; position: relative; }

.main-image-container {
    width: 100%;
    aspect-ratio: 1 / 1;
    max-height: 460px;
    background: var(--bg);
    display: flex; justify-content: center; align-items: center;
    padding: 10px;
    border-radius: 20px;
    border: 1px solid var(--border);
    overflow: hidden;
    position: relative;
    cursor: crosshair;
}

#main-product-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: transform 0.1s ease-out;
}

.gallery-indicator {
    position: absolute;
    top: 14px;
    inset-inline-start: 14px;
    background: rgba(0,0,0,0.65);
    backdrop-filter: blur(4px);
    color: #fff;
    font-size: 12px;
    font-weight: 800;
    padding: 4px 10px;
    border-radius: 20px;
    z-index: 5;
}

.discount-ribbon {
    position: absolute;
    top: 14px;
    inset-inline-end: 14px;
    background: var(--danger-dark);
    color: #fff;
    font-size: 13px;
    font-weight: 900;
    padding: 6px 13px;
    border-radius: 20px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    line-height: 1;
    z-index: 5;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.35);
}

.zoom-hint {
    position: absolute;
    bottom: 12px;
    inset-inline-end: 12px;
    width: 34px; height: 34px;
    border-radius: 50%;
    background: rgba(0,0,0,0.45);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px;
    pointer-events: none;
}
@media (hover: none), (max-width: 768px) {
    .zoom-hint { display: none; }
    .main-image-container { cursor: pointer; }
}

/* Related Products Section Title */
.related-section { margin-top: 48px; }
.related-section .section-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 20px;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--border);
}

/* Carousels */
.carousel-wrapper { position: relative; display: flex; align-items: center; width: 100%; }

.thumbnails, .products-scroll {
    display: flex; gap: 12px; overflow-x: auto; scroll-behavior: smooth;
    padding: 5px 35px;
    scrollbar-width: none; flex: 1;
}
.thumbnails::-webkit-scrollbar, .products-scroll::-webkit-scrollbar { display: none; }

.thumb-img {
    width: 72px; height: 72px; min-width: 72px;
    border-radius: 14px; object-fit: cover;
    cursor: pointer; opacity: 0.55;
    border: 2px solid transparent; background: var(--bg);
    transition: opacity .2s ease, border-color .2s ease, transform .2s ease;
}
.thumb-img:hover { opacity: 0.9; transform: translateY(-2px); }
.thumb-img.active { opacity: 1; border-color: var(--primary); box-shadow: 0 4px 12px rgba(0,0,0,0.12); }

/* Transparent Glass Arrows */
.scroll-arrow-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 38px; height: 38px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(6px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    color: var(--primary);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: 0.2s ease;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    z-index: 10; font-size: 14px;
}
body.dark-mode .scroll-arrow-btn { background: rgba(15, 23, 42, 0.8); border-color: rgba(255,255,255,0.1); }
.scroll-arrow-btn:hover { background: var(--primary); color: white; border-color: var(--primary); transform: translateY(-50%) scale(1.06); }

.carousel-wrapper .scroll-arrow-btn:first-child { right: 0; }
.carousel-wrapper .scroll-arrow-btn:last-child { left: 0; }

/* Uniform Suggested Product Card Sizing */
#suggestions-grid.products-scroll { align-items: stretch; }
#suggestions-grid .product-card {
    flex: 0 0 200px;
    width: 200px;
    display: flex;
    flex-direction: column;
}
#suggestions-grid .product-img {
    width: 100%;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    display: block;
}
#suggestions-grid .product-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
#suggestions-grid .product-info {
    flex: 1;
    display: flex;
    flex-direction: column;
}
#suggestions-grid .product-title {
    font-size: 14px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 38px;
}

/* Product Details */
.product-details { display: flex; flex-direction: column; width: 100%; }
@media (min-width: 769px) { .product-details { position: sticky; top: 100px; align-self: start; } }

.product-title { font-size: 28px; font-weight: 900; color: var(--text); margin-bottom: 18px; line-height: 1.35; }

/* Buy Box - Enhanced Shadow & Spacing */
.buy-box {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 28px;
    display: flex;
    flex-direction: column;
    gap: 22px;
    margin-bottom: 24px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.06);
}

.product-meta { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.price-tag { font-size: 36px; font-weight: 900; color: var(--primary); line-height: 1; }
.old-price-tag { font-size: 18px; color: var(--text-light); text-decoration: line-through; font-weight: 600; }

.discount-badge {
    background: var(--danger); color: #FFFFFF; font-size: 13px; font-weight: 900;
    padding: 4px 10px; border-radius: 8px; display: inline-flex; align-items: center; gap: 4px; line-height: 1;
}

.savings-pill {
    background: rgba(16, 185, 129, 0.12); color: var(--success); font-size: 13px; font-weight: 800;
    padding: 5px 12px; border-radius: 8px; display: inline-flex; align-items: center; gap: 6px; width: fit-content;
}

.stock-badge {
    padding: 6px 14px; border-radius: 30px; font-size: 13px; font-weight: 800; color: #FFFFFF;
    display: inline-flex; align-items: center; gap: 6px; line-height: 1;
}
.status-success { background: var(--success); }
.status-warning { background: var(--warning-alt); }
.status-danger { background: var(--danger); }

/* Trust Badges (delivery / payment / return) */
.trust-badges {
    display: flex; flex-wrap: wrap; gap: var(--space-sm) var(--space-lg);
    padding-top: var(--space-sm); margin-top: 2px;
    border-top: 1px dashed var(--border);
}
.trust-badges span {
    display: inline-flex; align-items: center; gap: 8px;
    font-size: 12.5px; font-weight: 700; color: var(--text-light);
}
.trust-badges span i { color: var(--primary); font-size: 14px; }

/* Quantity Selector Input */
.qty-wrapper { display: flex; align-items: center; gap: 15px; flex-wrap: wrap; }
.qty-label { font-weight: 800; font-size: 16px; color: var(--text); }
.qty-selector { display: flex; align-items: center; background: var(--white); border-radius: 30px; height: 46px; border: 2px solid var(--border); overflow: hidden; }
.qty-btn-detail { background: transparent; border: none; width: 44px; height: 100%; display: flex; align-items: center; justify-content: center; font-size: 14px; cursor: pointer; color: var(--text); transition: 0.2s; }
.qty-btn-detail:hover:not(:disabled) { background: var(--border); color: var(--primary); }

.qty-input-detail {
    width: 50px; text-align: center; font-weight: 900; font-size: 16px; color: var(--text);
    border: none; background: transparent; outline: none; -moz-appearance: textfield;
}
.qty-input-detail::-webkit-outer-spin-button, .qty-input-detail::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* Action Buttons */
.action-buttons { display: flex; gap: 12px; }
.btn {
    flex: 1; padding: 15px 18px; border-radius: 16px; font-size: 15px; font-weight: 900;
    border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px;
    transition: 0.2s ease; white-space: nowrap;
}
.btn-add { background: var(--primary-light); color: var(--primary); }
.btn-add:hover:not(:disabled) { background: var(--primary); color: white; }
.btn-buy { background: var(--warning); color: #0F172A; font-size: 16px; box-shadow: 0 6px 16px rgba(245, 158, 11, 0.25); }
.btn-buy:hover:not(:disabled) { box-shadow: 0 10px 22px rgba(245, 158, 11, 0.35); }
.btn:disabled { background: var(--white); border: 1px solid var(--border); color: var(--text-light); cursor: not-allowed; opacity: 0.65; }
.btn i { font-size: 14px; line-height: 1; }

/* Tabs Section (Description, QA) */
.tabs-container { margin-top: 20px; border: 1px solid var(--border); border-radius: 16px; overflow: hidden; background: var(--white); }
.tabs-header { display: flex; background: var(--bg); border-bottom: 1px solid var(--border); }
.tab-btn { flex: 1; padding: 14px; border: none; background: transparent; font-weight: 800; font-size: 14.5px; color: var(--text-light); cursor: pointer; transition: 0.2s; text-align: center; }
.tab-btn.active { color: var(--primary); background: var(--white); border-bottom: 3px solid var(--primary); }
.tab-content { padding: 20px; display: none; }
.tab-content.active { display: block; animation: fadeUp .3s ease; }

.product-desc { font-size: 15px; line-height: 1.9; color: var(--text); white-space: pre-line; }

/* Share Section */
.share-row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-top: 15px; padding: 14px 18px; background: var(--bg); border: 1px solid var(--border); border-radius: 16px; }
.share-label { font-size: 13.5px; font-weight: 800; color: var(--text-light); }
.share-icons { display: flex; gap: 10px; }
.share-icon-btn { width: 38px; height: 38px; min-width: 38px; border-radius: 50%; border: none; color: #fff; font-size: 15px; line-height: 1; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: transform .15s ease, filter .15s ease; }
.share-icon-btn:hover { transform: translateY(-2px); filter: brightness(1.05); }
.share-icon-btn.wa { background: var(--wa-color); }
.share-icon-btn.fb { background: var(--fb-color); }
.share-icon-btn.tg { background: var(--tg-color); }
.share-icon-btn.ig { background: radial-gradient(circle at 30% 107%, #fdf497 0%, #fdf497 5%, #fd5949 45%, #d6249f 60%, #285AEB 90%); }
.share-icon-btn.share-native { background: var(--primary); }

/* Read More / Read Less Description */
.desc-wrapper { position: relative; }
.desc-wrapper.collapsed .product-desc { max-height: 130px; overflow: hidden; }
.desc-fade { display: none; }
.desc-wrapper.collapsed .desc-fade {
    display: block;
    position: absolute; left: 0; right: 0; bottom: 0; height: 46px;
    background: linear-gradient(to bottom, rgba(255,255,255,0), var(--white));
    pointer-events: none;
}
.read-more-btn {
    display: none; align-items: center; gap: 6px; margin-top: 10px;
    background: none; border: none; color: var(--primary); font-weight: 800; font-size: 14px;
    cursor: pointer; padding: 4px 0;
}
.read-more-btn:hover { text-decoration: underline; }
.read-more-btn i { font-size: 12px; transition: transform .2s ease; }
.read-more-btn.expanded i { transform: rotate(180deg); }

/* Lightbox Navigation */
.image-lightbox { position: fixed; inset: 0; background: rgba(0,0,0,0.92); display: none; align-items: center; justify-content: center; z-index: 1000; padding: 20px; }
.image-lightbox.show { display: flex; }
.image-lightbox img { max-width: 90%; max-height: 85vh; object-fit: contain; border-radius: 8px; }
.lightbox-close { position: absolute; top: 20px; inset-inline-end: 20px; width: 44px; height: 44px; border-radius: 50%; background: rgba(255,255,255,0.2); border: none; color: #fff; font-size: 20px; cursor: pointer; }
.lightbox-nav { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(255,255,255,0.2); border: none; color: #fff; font-size: 22px; width: 48px; height: 48px; border-radius: 50%; cursor: pointer; }
.lightbox-prev { inset-inline-start: 20px; }
.lightbox-next { inset-inline-end: 20px; }

/* Snackbar & Toasts */
.snackbar-container { position: fixed; bottom: 20px; inset-inline-start: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; }
.snackbar { background: #1F2937; color: #fff; padding: 14px 22px; border-radius: 12px; font-weight: 700; font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,0.25); display: flex; align-items: center; justify-content: space-between; gap: 18px; animation: fadeUp 0.3s ease; }
.snackbar-btn { background: var(--primary); color: white; border: none; padding: 6px 12px; border-radius: 8px; cursor: pointer; font-weight: 800; font-size: 12px; }

/* Skeletons */
.skeleton-wrapper { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; }
.skeleton-box { position: relative; overflow: hidden; background: var(--border); border-radius: 16px; }
.skeleton-box::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.35) 50%, transparent 100%);
    transform: translateX(-100%);
    animation: skeletonLoading 1.5s infinite;
    will-change: transform;
}
.skeleton-gallery { height: 500px; }
.skeleton-details { min-height: 500px; }
@keyframes skeletonLoading { 100% { transform: translateX(100%); } }

/* Mobile Buy Bar (mobile only — hidden on desktop, see media query below) */
.mobile-buy-bar { position: fixed; left: 0; right: 0; bottom: 0; background: var(--white); border-top: 1px solid var(--border); box-shadow: 0 -6px 24px rgba(0,0,0,0.08); padding: 10px 16px; z-index: 500; transform: translateY(100%); transition: transform .25s ease; }
.mobile-buy-bar.visible { transform: translateY(0); }
.mbb-inner { max-width: 1100px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.mbb-info { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1 1 auto; }
.mbb-thumb { width: 40px; height: 40px; min-width: 40px; border-radius: 10px; object-fit: cover; }
.mbb-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.mbb-title { font-weight: 800; font-size: 12.5px; color: var(--text-light); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.2; }
.mobile-buy-price { font-size: 17px; font-weight: 900; color: var(--primary); line-height: 1.2; }
.mobile-buy-actions { display: flex; gap: 8px; flex-shrink: 0; }
.mobile-buy-actions .btn { padding: 11px 14px; font-size: 13.5px; white-space: nowrap; }
.mobile-buy-actions #mobile-add-btn { flex: 0 0 auto; padding: 11px 16px; }

/* While the cart sidebar is open, always hide the sticky buy bar so it
   never overlaps the cart's checkout button. */
body.cart-open .mobile-buy-bar { transform: translateY(100%); }

/* Reserve bottom space ONLY while the bar is actually visible on screen —
   the exact amount is set dynamically in JS to match the bar's real height,
   so it never leaves extra empty space. */
body { transition: padding-bottom .25s ease; }

/* Desktop: the sticky buy bar gets bigger, roomier proportions */
@media (min-width: 769px) {
    .mobile-buy-bar { padding: 18px 32px; }
    .mbb-inner { gap: 24px; }
    .mbb-info { gap: 16px; }
    .mbb-thumb { width: 60px; height: 60px; min-width: 60px; border-radius: 14px; }
    .mbb-title { font-size: 16px; max-width: 340px; color: var(--text); }
    .mobile-buy-price { font-size: 24px; }
    .mobile-buy-actions { gap: 12px; }
    .mobile-buy-actions .btn { padding: 16px 28px; font-size: 15.5px; border-radius: 14px; }
    .mobile-buy-actions #mobile-add-btn { padding: 16px 22px; }
    .mobile-buy-actions #mobile-add-btn i { font-size: 18px; }
}

/* Quick View Modal */
.quick-view-modal { position: fixed; inset: 0; background: rgba(0,0,0,0.7); display: none; align-items: center; justify-content: center; z-index: 1000; padding: 20px; }
.quick-view-modal.show { display: flex; }
.quick-view-content { background: var(--white); border-radius: 20px; max-width: 700px; width: 100%; padding: 24px; position: relative; max-height: 90vh; overflow-y: auto; }
.qv-close { position: absolute; top: 15px; inset-inline-end: 15px; background: transparent; border: none; font-size: 20px; cursor: pointer; color: var(--text); }

/* Focus and Accessibility */
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; } }

/* Responsive Adjustments */

/* Tablet */
@media (max-width: 1024px) {
    .container { max-width: 100%; }
    .product-essential { gap: var(--space-lg); }
    .main-image-container { max-height: 400px; }
    #suggestions-grid .product-card { flex: 0 0 180px; width: 180px; }
}

/* Mobile */
@media (max-width: 768px) {
    .container { margin: 16px auto; }
    .product-essential { grid-template-columns: 1fr; padding: var(--space-md); gap: var(--space-md); border-radius: 18px; }
    .skeleton-wrapper { grid-template-columns: 1fr; }
    .main-image-container { max-height: 320px; border-radius: 16px; }
    .product-title { font-size: 22px; margin-bottom: var(--space-md); }
    .buy-box { padding: var(--space-md); gap: var(--space-md); border-radius: 16px; }
    .price-tag { font-size: 26px; }
    .old-price-tag { font-size: 15px; }
    .qty-wrapper { gap: var(--space-sm); }
    .qty-selector { height: 42px; }
    .qty-btn-detail { width: 40px; }
    .action-buttons { gap: var(--space-sm); }
    .btn { padding: 13px 14px; font-size: 14px; }
    .trust-badges { gap: var(--space-xs) var(--space-md); }
    .trust-badges span { font-size: 12px; }
    .thumb-img { width: 60px; height: 60px; min-width: 60px; }
    .scroll-arrow-btn { width: 32px; height: 32px; font-size: 12px; }
    .share-row { padding: var(--space-sm) var(--space-md); }
    .thumbnails, .products-scroll { padding: 5px 30px; gap: var(--space-sm); }
    #suggestions-grid .product-card { flex: 0 0 155px; width: 155px; }
    #suggestions-grid .product-title { font-size: 13px; min-height: 34px; }
    .share-icons { gap: 8px; }
    .share-icon-btn { width: 34px; height: 34px; min-width: 34px; font-size: 13px; }
    .quick-view-content { padding: var(--space-md); border-radius: 16px; }
    .mobile-buy-bar { padding: 10px var(--space-md); }
    .desc-wrapper.collapsed .product-desc { max-height: 110px; }
}

/* Extra-narrow phones: drop the thumbnail to keep title + price readable */
@media (max-width: 360px) {
    .mbb-thumb { display: none; }
    .mbb-title { max-width: 140px; }
}

/* Small phones */
@media (max-width: 400px) {
    .container { padding: 0 var(--space-sm); }
    .product-essential { padding: var(--space-sm); }
    .action-buttons { flex-direction: column; }
    .qty-wrapper { justify-content: space-between; width: 100%; }
    .price-tag { font-size: 22px; }
    .gallery-indicator { font-size: 11px; padding: 3px 8px; }
    .share-label { font-size: 12.5px; }
    #suggestions-grid .product-card { flex: 0 0 135px; width: 135px; }
    .share-row { justify-content: center; }
    .share-label { width: 100%; text-align: center; }
}