/* ========================================
   MEMOART V4 - Product & Cart Pages
   Premium DA + Fixed Upload + Realistic Frame
   ======================================== */

/* Product Page */
.product-page {
    padding-top: 80px;
    min-height: 100vh;
    background: var(--bg-cream);
}

.product-container {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
    padding: var(--space-md) 0;
}

/* Preview Zone */
.preview-zone {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
    box-shadow: var(--shadow-md);
}

.preview-title {
    font-family: 'Playfair Display', serif;
    font-size: 1.1rem;
    font-weight: 500;
    margin-bottom: var(--space-md);
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

/* Preview Container - The frame area */
.preview-container {
    position: relative;
    width: 100%;
    aspect-ratio: 3/4;
    max-width: 320px;
    margin: 0 auto var(--space-md);
    background: #FFFFFF;
    border-radius: 4px;
    overflow: visible;
    /* Allow frame shadow to show */
}

/* The photo mask - ALWAYS behind overlay */
.preview-mask {
    position: absolute;
    inset: 0;
    overflow: hidden;
    cursor: grab;
    z-index: 1;
    /* Below template overlay */
    border-radius: 2px;
}

.preview-mask:active {
    cursor: grabbing;
}

/* The uploaded photo */
.preview-image {
    position: absolute;
    left: 50%;
    top: 50%;
    min-width: 100%;
    min-height: 100%;
    transform-origin: center center;
    user-select: none;
    -webkit-user-drag: none;
    object-fit: cover;
}

/* Template Overlay - ALWAYS visible on top */
.template-overlay-preview {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 5;
    /* Always above photo */
}

/* Upload Zone - Visible when no photo */
.upload-zone {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--text-light);
    padding: var(--space-lg);
    background: var(--bg-light);
    border: 2px dashed var(--border);
    border-radius: 4px;
    cursor: pointer;
    transition: var(--transition-normal);
    z-index: 20;
    /* Above everything when visible */
}

.upload-zone:hover {
    border-color: var(--primary);
    background: rgba(26, 26, 26, 0.02);
}

.upload-icon {
    font-size: 2.5rem;
    margin-bottom: var(--space-sm);
    opacity: 0.6;
}

.upload-text {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-body);
}

.upload-hint {
    font-size: 0.75rem;
    margin-top: var(--space-xs);
    color: var(--text-light);
}

/* ========================================
   REALISTIC FRAME BORDER (Like reference image)
   ======================================== */
.frame-border {
    position: absolute;
    inset: -12px;
    /* Extend outside container */
    pointer-events: none;
    z-index: 50;
    border-radius: 4px;
}

/* Black Frame - Main style from reference */
.frame-border.frame-black {
    background: transparent;
    border: 12px solid #1a1a1a;
    box-shadow:
        /* Inner shadow for depth */
        inset 0 0 0 2px rgba(255, 255, 255, 0.1),
        inset 0 2px 4px rgba(0, 0, 0, 0.3),
        /* Outer shadow for realism */
        0 20px 60px rgba(0, 0, 0, 0.25),
        0 8px 25px rgba(0, 0, 0, 0.15);
}

/* White Frame */
.frame-border.frame-white {
    background: transparent;
    border: 12px solid #ffffff;
    box-shadow:
        inset 0 0 0 1px rgba(0, 0, 0, 0.05),
        inset 0 2px 4px rgba(0, 0, 0, 0.08),
        0 20px 60px rgba(0, 0, 0, 0.12),
        0 8px 25px rgba(0, 0, 0, 0.08);
}

/* ========================================
   FRAME COLOR SELECTOR
   ======================================== */
.frame-color-selector {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    margin-top: var(--space-md);
    padding: var(--space-sm);
    background: var(--bg-light);
    border-radius: var(--radius-md);
}

.frame-color-label {
    font-size: 0.85rem;
    color: var(--text-light);
}

.frame-color-options {
    display: flex;
    gap: var(--space-xs);
}

.frame-color-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid transparent;
    padding: 3px;
    background: white;
    cursor: pointer;
    transition: var(--transition-fast);
}

.frame-color-btn span {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 50%;
}

.frame-color-btn:hover {
    transform: scale(1.1);
}

.frame-color-btn.active {
    border-color: var(--primary);
}

/* ========================================
   WOOD PREMIUM CHECKBOX
   ======================================== */
.wood-option {
    margin-top: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-warm);
    border-radius: var(--radius-md);
    border: 2px solid transparent;
    transition: var(--transition-fast);
}

.wood-option:has(input:checked) {
    border-color: var(--accent);
    background: var(--accent-light);
}

.wood-checkbox-label {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    cursor: pointer;
    font-size: 0.9rem;
}

.wood-checkbox-label input {
    display: none;
}

.wood-checkbox-custom {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-radius: 4px;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: var(--transition-fast);
}

.wood-checkbox-label input:checked+.wood-checkbox-custom {
    background: var(--primary);
    border-color: var(--primary);
}

.wood-checkbox-label input:checked+.wood-checkbox-custom::after {
    content: '✓';
    color: white;
    font-size: 0.75rem;
    font-weight: bold;
}

.wood-checkbox-text {
    flex: 1;
    color: var(--text-dark);
}

.wood-price {
    color: var(--accent);
    font-weight: 600;
}

/* ========================================
   ZOOM CONTROL
   ======================================== */
.zoom-control {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm);
    background: var(--bg-light);
    border-radius: var(--radius-md);
    margin-top: var(--space-sm);
}

.zoom-control label {
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
}

.zoom-slider {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
}

.zoom-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
}

/* ========================================
   CONFIG ZONE
   ======================================== */
.config-zone {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
    box-shadow: var(--shadow-md);
}

.config-section {
    margin-bottom: var(--space-lg);
    padding-bottom: var(--space-md);
    border-bottom: 1px solid var(--border);
}

.config-section:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.config-title {
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: var(--space-sm);
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

/* Options Grid */
.options-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-xs);
}

.option-card {
    position: relative;
}

.option-card input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.option-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--space-sm);
    background: var(--bg-light);
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-fast);
    text-align: center;
}

.option-card input:checked+.option-label {
    border-color: var(--primary);
    background: rgba(26, 26, 26, 0.03);
}

.option-name {
    font-size: 0.85rem;
    font-weight: 500;
}

.option-price {
    font-size: 0.75rem;
    color: var(--text-light);
}

.option-price.extra {
    color: var(--accent);
    font-weight: 600;
}

/* Template Inputs */
.template-inputs {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.input-group label {
    font-size: 0.85rem;
    font-weight: 500;
}

.input-group input,
.input-group textarea {
    width: 100%;
    padding: var(--space-sm);
    background: var(--bg-light);
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    transition: var(--transition-fast);
}

.input-group input:focus,
.input-group textarea:focus {
    border-color: var(--primary);
    background: var(--bg-white);
}

.input-group input::placeholder {
    color: var(--text-light);
}

.input-required {
    color: var(--accent);
}

.input-hint {
    font-size: 0.75rem;
    color: var(--text-light);
}

.link-input-wrapper {
    position: relative;
}

.link-input-wrapper input {
    padding-left: 2.5rem;
}

.link-icon {
    position: absolute;
    left: var(--space-sm);
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
}

/* ========================================
   PRICE SECTION
   ======================================== */
.price-section {
    background: var(--bg-warm);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
    text-align: center;
}

.price-label {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-bottom: var(--space-xs);
}

.price-total {
    font-family: 'Playfair Display', serif;
    font-size: 2.5rem;
    font-weight: 600;
    color: var(--text-dark);
}

.price-details {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-top: var(--space-xs);
}

.add-to-cart-btn {
    width: 100%;
    padding: var(--space-md);
    font-size: 1rem;
    font-weight: 600;
    margin-top: var(--space-md);
}

.add-to-cart-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* ========================================
   NEW PROMO STYLES
   ======================================== */
.product-price-red {
    color: #E53935 !important;
}

.discount-badge-product {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #E53935;
    color: white;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 800;
    margin-left: 10px;
    vertical-align: middle;
    transform: translateY(-4px);
    /* Align visual adjustment */
    box-shadow: 0 4px 10px rgba(229, 57, 53, 0.3);
}

.dynamic-badge-container {
    margin-bottom: 10px;
    /* height: 30px; */
    /* REMOVED to avoid empty space */
    display: none;
    /* Hidden by default, toggled by JS */
    align-items: center;
    justify-content: flex-start;
    /* Default left align */
}

/* Mobile Adjustment: Centered badge */
@media (max-width: 768px) {
    .preview-title {
        text-align: center;
        margin-bottom: 10px;
    }

    .dynamic-badge-container {
        justify-content: center;
        margin-bottom: 15px;
    }
}

.dynamic-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    color: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    animation: fadeInDown 0.4s ease;

    /* VITAL FIX: Reset positioning for reused classes like badge-popular */
    position: static !important;
    top: auto !important;
    left: auto !important;
    transform: none !important;
    margin: 0 !important;
}

/* Badge Variants */
.badge-bestseller {
    background: linear-gradient(135deg, #FFD700, #FFA500);
    color: #1a1a1a;
}

.badge-popular {
    background: linear-gradient(135deg, #FF6B35, #E83E3E);
}

.badge-new {
    background: linear-gradient(135deg, #7C3AED, #A855F7);
}

.badge-gift {
    background: linear-gradient(135deg, #10B981, #059669);
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.product-trust {
    display: flex;
    justify-content: center;
    gap: var(--space-md);
    margin-top: var(--space-md);
    padding-top: var(--space-md);
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}

.product-trust-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    color: var(--text-light);
}

/* ========================================
   CART PAGE
   ======================================== */
/* ========================================
   CART PAGE (RESET STRUCTURE)
   ======================================== */
.cart-page {
    padding-top: 80px;
    min-height: 100vh;
}

/* Conteneur principal qui prend toute la hauteur disponible */
.cart-wrapper {
    display: flex;
    flex-direction: column;
    min-height: 70vh;
    /* Laisse de la place pour le header et le footer */
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    /* Un peu de marge sur les côtés */
    padding-top: 100px;
    /* Ajout perso pour le header fixed */
    width: 100%;
}

/* Titre en haut */
.cart-header h1 {
    text-align: left;
    margin-bottom: 20px;
    font-size: 28px;
    /* Ta police serif ici */
}

/* Zone du message vide : prend tout l'espace restant */
.empty-cart-container {
    flex-grow: 1;
    /* C'est la clé : il pousse le footer vers le bas */
    display: flex;
    justify-content: center;
    /* Centre horizontalement */
    align-items: center;
    /* Centre verticalement */
    width: 100%;
}

/* Le contenu du message */
.empty-content {
    text-align: center;
    max-width: 600px;
}

.empty-content h2 {
    font-size: 24px;
    margin-bottom: 10px;
}

.empty-content p {
    color: #666;
    margin-bottom: 25px;
    line-height: 1.5;
}

.cart-items {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.cart-item {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
    box-shadow: var(--shadow-md);
    display: flex;
    gap: var(--space-md);
}

.cart-item-preview {
    width: 100px;
    height: 130px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    flex-shrink: 0;
    background: var(--bg-light);
}

.cart-item-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cart-item-details {
    flex: 1;
}

.cart-item-name {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: var(--space-xs);
}

.cart-item-options {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-bottom: var(--space-sm);
}

.cart-item-price {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-dark);
}

.cart-item-remove {
    background: none;
    color: var(--text-light);
    font-size: 0.85rem;
    padding: var(--space-xs);
    margin-top: var(--space-xs);
}

.cart-item-remove:hover {
    color: var(--accent);
}

/* Cart Summary */
.cart-summary {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
    box-shadow: var(--shadow-md);
    margin-top: var(--space-lg);
}

.cart-summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-xs) 0;
}

.cart-summary-row.total {
    font-size: 1.25rem;
    font-weight: 700;
    border-top: 2px solid var(--border);
    padding-top: var(--space-sm);
    margin-top: var(--space-sm);
}

.cart-summary-row.total .price {
    color: var(--text-dark);
}

.checkout-btn {
    width: 100%;
    margin-top: var(--space-md);
}

/* ========================================
   DESKTOP RESPONSIVE
   ======================================== */
@media (min-width: 768px) {
    .product-container {
        flex-direction: row;
    }

    .preview-zone {
        flex: 1;
        position: sticky;
        top: 100px;
        height: fit-content;
    }

    .config-zone {
        flex: 1;
    }

    .preview-container {
        max-width: 380px;
    }
}

/* Micro-Vignettes Style Custom overrides */
.template-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr) !important;
    gap: 10px;
}

.template-btn {
    width: 48px !important;
    height: 48px !important;
    padding: 0 !important;
    border: 1px solid #eee;
    border-radius: 8px !important;
    overflow: hidden;
    transition: all 0.2s ease;
    background: #f5f5f5;
}

.template-btn img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.template-btn.active {
    border: 2px solid #000 !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: scale(1.05);
    background: transparent !important;
}

.template-btn:hover {
    transform: translateY(-2px);
}

.config-title {
    color: #333;
    font-size: 0.75rem !important;
    letter-spacing: 1px;
    text-transform: uppercase;
    font-weight: 700 !important;
    margin-bottom: 15px !important;
}

.btn-clean-upload:hover {
    background: #000 !important;
    color: #fff !important;
}

/* Product Reassurance Block (Horizontal Minimal) */
.product-reassurance-row {
    margin-top: 15px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    width: 100%;
}

.reassurance-item-minimal {
    font-size: 0.75rem;
    color: #666;
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 400;
}

.reassurance-separator {
    color: #ccc;
    font-size: 0.6rem;
}

/* Price Reviews Block */
.price-reviews-block {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 20px;
}

.price-stars {
    font-size: 0.8rem;
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.1));
}

.price-reviews-text {
    font-size: 0.8rem;
    color: #444;
    font-weight: 500;
    text-decoration: underline;
    text-decoration-color: #ddd;
}

/* Best Seller Badge */
.btn-bestseller {
    position: relative;
    overflow: visible !important;
    border-color: #000 !important;
    /* Petit highlight de la border */
}

.bestseller-badge {
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    background: #000;
    color: #fff;
    font-size: 0.6rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    z-index: 10;
    white-space: nowrap;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* ========================================
   NEW SECTIONS (How it works, Gallery, Details)
   ======================================== */

.product-section {
    padding: 60px 20px;
    background: #fff;
    margin-top: 40px;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
}

.section-title-center {
    text-align: center;
    font-family: 'Playfair Display', serif;
    font-size: 1.8rem;
    margin-bottom: 40px;
    color: #1a1a1a;
}

/* How It Works */
.steps-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 30px;
    text-align: center;
}

.step-card {
    padding: 20px;
}

.step-img-icon {
    width: 80px;
    height: 80px;
    display: block;
    margin: 0 auto 15px;
    object-fit: contain;
}

.step-card h3 {
    font-size: 1.1rem;
    margin-bottom: 10px;
    font-weight: 700;
}

.step-card p {
    font-size: 0.9rem;
    color: #666;
    line-height: 1.5;
}

/* Dynamic Gallery */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
}

.gallery-item {
    aspect-ratio: 1;
    border-radius: 12px;
    overflow: hidden;
    background: #f5f5f5;
    transition: transform 0.3s ease;
}

.gallery-item:hover {
    transform: scale(1.02);
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Details & Quality */
.details-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 30px;
}

.detail-item {
    display: flex;
    gap: 15px;
    align-items: flex-start;
}

.detail-item i {
    font-size: 1.8rem;
    color: #C9A86C;
    flex-shrink: 0;
    margin-top: 5px;
}

.detail-text h4 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 5px;
    color: #1a1a1a;
}

.detail-text p {
    font-size: 0.95rem;
    color: #555;
    line-height: 1.5;
}

/* Responsive */
@media (max-width: 900px) {
    .steps-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .details-grid {
        grid-template-columns: 1fr;
    }
}

/* ========================================
   REVIEWS GRID (WALL OF LOVE) - FORCED FIX
   ======================================== */

.reviews-masonry {
    padding: 0 0 60px;
    background: #F9F5F0;
    /* Cream background */
}

/* Container: Force Grid */
.masonry-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    max-width: 1400px;
    margin: 0 auto;
    padding: 40px 20px;
    box-sizing: border-box;
}

/* Card Style */
.review-card {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    height: 100%;
    transition: transform 0.3s ease;
}

.review-card:hover {
    transform: translateY(-5px);
}

/* Image Style */
/* Image Style - Force Square (Robust Method) */
.review-image {
    width: 100%;
    /* Padding hack for aspect ratio 1:1 if aspect-ratio fails */
    padding-bottom: 100%;
    position: relative;
    overflow: hidden;
    margin: 0;
}

.review-image img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
}

/* Content Style */
.review-content {
    padding: 20px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.review-stars {
    color: #FFC107;
    font-size: 0.9rem;
    margin-bottom: 12px;
}

.review-text {
    font-size: 0.95rem;
    color: #444;
    line-height: 1.6;
    margin-bottom: 15px;
    font-style: italic;
    flex-grow: 1;
}

.review-author {
    font-weight: 700;
    font-size: 0.9rem;
    color: #1a1a1a;
}

/* Responsive */
@media (max-width: 1024px) {
    .masonry-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .masonry-grid {
        grid-template-columns: 1fr;
    }
}