/* ==========================================
   PRODUCT MODAL COMPONENT - PREMIUM DESIGN
   Refactored for Elegance and Focus
   ========================================== */

/* Variables */
:root {
    --modal-bg: #ffffff;
    --modal-overlay: rgba(20, 20, 20, 0.7);
    --modal-text-primary: #1a1a1a;
    --modal-text-secondary: #555555;
    --modal-accent: #742429; /* Marsala */
    --modal-gold: #C5A065;   /* Gold/Sand */
    --modal-border: #e6e6e6;
    --modal-font-heading: 'Oranienbaum', serif;
    --modal-font-body: 'Inter', sans-serif;
}

.product-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    display: flex; /* Changed from none to flex for centering */
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

.product-modal.active {
    opacity: 1;
    visibility: visible;
}

/* Backdrop with Blur */
.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--modal-overlay);
    backdrop-filter: blur(8px);
    z-index: 1;
}

/* Modal Card */
.modal-content {
    background: var(--modal-bg);
    width: 95%;
    max-width: 1100px;
    height: 85vh; /* Fixed height for consistent layout */
    max-height: 800px;
    border-radius: 16px;
    position: relative;
    z-index: 2;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(30px) scale(0.98);
    transition: transform 0.4s cubic-bezier(0.19, 1, 0.22, 1);
}

.product-modal.active .modal-content {
    transform: translateY(0) scale(1);
}

/* Close Button - Minimalist & Elegant */
.modal-close {
    position: absolute;
    top: 24px;
    right: 24px;
    background: transparent;
    border: none;
    color: #bbb;
    cursor: pointer;
    z-index: 20;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.19, 1, 0.22, 1);
}

.modal-close i {
    font-size: 1.2rem;
    /* font-weight removed to allow FA default (900/Solid) */
}

.modal-close:hover {
    background: rgba(116, 36, 41, 0.08); /* Very light Marsala tint */
    color: var(--modal-accent);
    transform: rotate(90deg) scale(1.1);
}

/* Modal Body - Grid Layout */
.modal-body {
    display: grid;
    grid-template-columns: 45% 55%;
    height: 100%;
    width: 100%;
}

/* LEFT: Gallery Section */
.modal-gallery-section {
    background: #f9f9f9;
    padding: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    border-right: 1px solid var(--modal-border);
}

.gallery-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
}

.main-image {
    max-width: 100%;
    max-height: 75%; /* Reduz para dar espaço para short-desc */
    object-fit: contain;
    mix-blend-mode: multiply; /* Helps blend white bg images */
    filter: contrast(1.02);
    transition: transform 0.3s ease;
}

.main-image:hover {
    transform: scale(1.05);
}

/* Short Description abaixo da imagem (Wine Modal) */
.gallery-short-desc {
    font-family: var(--modal-font-heading);
    font-size: 0.9rem; /* Menor que a versão sidebar */
    line-height: 1.4;
    color: var(--modal-text-secondary);
    font-style: italic;
    text-align: center;
    max-width: 90%;
    padding: 1rem;
    border-top: 2px solid var(--modal-gold);
    border-bottom: 2px solid var(--modal-gold);
}

.gallery-short-desc p {
    margin: 0;
}

/* RIGHT: Details Section */
.modal-details-section {
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
    background: #fff;
    overflow: hidden; /* Prevent outer scroll */
}

/* 1. Static Top Section */
.details-top-section {
    flex: 0 0 auto; /* Don't shrink or grow */
    padding: 2.5rem 3rem 1rem 3rem;
    background: #fff;
    z-index: 2;
}

/* 2. Scrollable Middle Body */
.details-scroll-body {
    flex: 1; /* Take remaining space */
    overflow-y: auto;
    padding: 0 3rem 2rem 3rem;
    position: relative;
    /* Scroll shadow hint (optional, kept simple for now) */
}

/* Custom Scrollbar */
.custom-scrollbar::-webkit-scrollbar {
    width: 6px;
}
.custom-scrollbar::-webkit-scrollbar-track {
    background: transparent;
}
.custom-scrollbar::-webkit-scrollbar-thumb {
    background-color: #ddd;
    border-radius: 20px;
}
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background-color: var(--modal-accent);
}

/* Typography & Info */

.product-category {
    display: block;
    font-family: var(--modal-font-body);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--modal-gold);
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.product-title {
    font-family: var(--modal-font-heading);
    font-size: 2.5rem;
    line-height: 1.1;
    color: var(--modal-text-primary);
    margin: 0 0 0.5rem 0;
    font-weight: 400;
}

.product-meta {
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 15px;
}

.product-code {
    font-family: var(--modal-font-body);
    font-size: 0.8rem;
    color: #999;
    /* background: #f5f5f5; Removed badge style */
    /* padding: 2px 8px; */
    /* border-radius: 4px; */
}

/* Price */
.modal-price-container {
    margin-bottom: 2rem;
    display: flex;
    align-items: flex-start;
    gap: 4px;
    color: var(--modal-accent);
}

.modal-price-container .currency {
    font-size: 1.2rem;
    font-family: var(--modal-font-body);
    margin-top: 8px;
    font-weight: 500;
}

.modal-price-container .price-value {
    font-size: 3rem;
    font-family: var(--modal-font-heading);
    font-weight: 700;
    line-height: 1;
}

/* Short Description - HIGHLIGHT */
.product-short-desc {
    font-family: var(--modal-font-heading); /* Serif for elegance */
    font-size: 1.2rem;
    line-height: 1.5;
    color: var(--modal-text-secondary);
    font-style: italic;
    margin-bottom: 1rem;
    padding-left: 1.5rem;
    border-left: 3px solid var(--modal-gold);
}

.product-short-desc p {
    margin: 0;
}

/* Full Description */
.product-full-desc {
    margin-top: 1rem;
    padding-top: 2rem;
    border-top: 1px solid var(--modal-border);
}

.product-full-desc h4 {
    font-family: var(--modal-font-body);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #999;
    margin-bottom: 1rem;
    font-weight: 600;
}

.product-full-desc .text-content {
    font-family: var(--modal-font-body);
    font-size: 0.95rem;
    line-height: 1.7;
    color: #666;
    text-align: justify;
}

.product-full-desc p {
    margin-bottom: 1rem;
}

/* ========================================
   WINE SPECS SECTION - DESIGN REFINADO E DELICADO
   ======================================== */

.wine-specs-section {
    margin-top: 2.5rem;
    padding-top: 2rem;
    border-top: 1px solid #f0f0f0;
    position: relative;
}

/* Ornamento superior mais delicado */
.wine-specs-section::before {
    content: '';
    position: absolute;
    top: -1px;
    left: 50%;
    transform: translateX(-50%);
    width: 50px;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--modal-gold), transparent);
}

.wine-specs-section h3 {
    font-family: var(--modal-font-heading);
    font-size: 1.5rem;
    color: var(--modal-accent);
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    font-weight: 300;
    letter-spacing: 0.8px;
    text-transform: uppercase;
}

.wine-specs-section h3 i {
    color: var(--modal-gold);
    font-size: 1.3rem;
    background: linear-gradient(135deg, rgba(197, 160, 101, 0.1), rgba(197, 160, 101, 0.03));
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

/* Container: Grid mais compacto */
.specs-scroll-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 16px;
}

/* Spec Item - Card mais delicado */
.spec-item {
    background: linear-gradient(135deg, #ffffff 0%, #fafafa 100%);
    border: 1px solid #f5f5f5;
    border-radius: 10px;
    padding: 18px;
    display: flex;
    align-items: center;
    gap: 15px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.spec-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--modal-gold), var(--modal-accent));
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.spec-item:hover::before {
    transform: scaleX(1);
}

.spec-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.06);
    border-color: rgba(197, 160, 101, 0.25);
}

/* Ícone em círculo dourado - AJUSTADO 38px */
.spec-item > i {
    font-size: 1.2rem;
    color: #ffffff;
    width: 38px;
    height: 38px;
    min-width: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #c5a065 0%, #a68351 100%);
    border-radius: 50%;
    box-shadow: 0 3px 10px rgba(197, 160, 101, 0.2);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

/* Usando ::after para não conflitar com FontAwesome ::before */
.spec-item > i::after {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(197, 160, 101, 0.12), transparent);
    z-index: -1;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.spec-item:hover > i {
    transform: scale(1.05) rotate(2deg);
    box-shadow: 0 3px 10px rgba(197, 160, 101, 0.25);
}

.spec-item:hover > i::after {
    opacity: 1;
}

/* Conteúdo */
.spec-content {
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex: 1;
    min-width: 0;
}

.spec-label {
    font-family: var(--modal-font-body);
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 1.8px;
    color: var(--modal-gold);
    font-weight: 700;
    margin-bottom: 3px;
}

.spec-value {
    font-family: var(--modal-font-body);
    font-size: 0.95rem;
    color: var(--modal-text-primary);
    font-weight: 400;
    line-height: 1.4;
    letter-spacing: 0.2px;
}

/* Grupos de Specs - ESPAÇAMENTO REDUZIDO */
.spec-group {
    margin-bottom: 0.6rem;
    padding-bottom: 0.6rem;
    position: relative;
}

.spec-group:not(:last-child)::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 70%;
    height: 1px;
    background: linear-gradient(90deg, transparent, #f0f0f0, transparent);
}

.spec-group h4 {
    font-family: var(--modal-font-heading);
    font-size: 1.1rem;
    color: var(--modal-accent);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 1.2px;
}

.spec-group h4 i {
    font-size: 1rem;
    color: var(--modal-gold);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(197, 160, 101, 0.08) 0%, rgba(197, 160, 101, 0.02) 100%);
    border-radius: 50%;
    border: 1px solid rgba(197, 160, 101, 0.15);
}

/* Layout compacto para itens curtos */
.spec-items-compact {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.spec-items-compact .spec-item {
    padding: 16px;
}

/* Empty State */
.empty-specs-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    text-align: center;
    background: linear-gradient(135deg, #fafafa 0%, #ffffff 100%);
    border-radius: 12px;
    border: 1px dashed #e8e8e8;
}

.empty-specs-message i {
    font-size: 3.5rem;
    margin-bottom: 1.5rem;
    background: linear-gradient(135deg, #c5a065, #a68351);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    opacity: 0.3;
}

.empty-specs-message p {
    font-size: 1rem;
    font-style: italic;
    font-family: var(--modal-font-heading);
    color: #aaa;
    font-weight: 300;
    letter-spacing: 0.4px;
}

/* Responsive */
@media (max-width: 1024px) {
    .specs-scroll-container {
        grid-template-columns: 1fr;
    }
    
    .spec-items-compact {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .wine-specs-section h3 {
        font-size: 1.3rem;
    }
    
    .spec-item {
        padding: 15px;
    }
    
    .spec-item > i {
        width: 42px;
        height: 42px;
        min-width: 42px;
        font-size: 1.3rem;
    }
    
    .spec-label {
        font-size: 0.6rem;
        letter-spacing: 1.5px;
    }
    
    .spec-value {
        font-size: 0.9rem;
    }
    
    .spec-group h4 {
        font-size: 1rem;
    }
}

/* Animação de entrada mais suave */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(15px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.spec-item {
    animation: fadeInUp 0.4s ease-out backwards;
}

.spec-item:nth-child(1) { animation-delay: 0.04s; }
.spec-item:nth-child(2) { animation-delay: 0.08s; }
.spec-item:nth-child(3) { animation-delay: 0.12s; }
.spec-item:nth-child(4) { animation-delay: 0.16s; }
.spec-item:nth-child(5) { animation-delay: 0.2s; }
.spec-item:nth-child(6) { animation-delay: 0.24s; }

/* Sticky Footer Actions */
.modal-actions-footer {
    position: relative; /* Changed from absolute */
    flex: 0 0 auto; /* Don't shrink */
    width: 100%;
    background: #fff;
    padding: 1.5rem 3rem;
    border-top: 1px solid var(--modal-border);
    display: flex;
    align-items: center;
    gap: 20px;
    z-index: 10;
    box-shadow: 0 -5px 20px rgba(0,0,0,0.03);
}

/* Quantity Control */
.quantity-control {
    display: flex;
    align-items: center;
    border: 1px solid #ddd;
    border-radius: 8px; /* Elegant radius */
    padding: 5px;
    height: 54px;
    background: #fff;
    transition: border-color 0.3s;
}

.quantity-control:hover {
    border-color: var(--modal-accent);
}

.qty-btn {
    width: 40px;
    height: 100%;
    border: none;
    background: transparent;
    color: var(--modal-text-secondary);
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.3s;
}

.qty-btn:hover {
    color: var(--modal-accent);
}

.qty-input {
    width: 50px;
    border: none;
    text-align: center;
    font-family: var(--modal-font-body);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--modal-text-primary);
    background: transparent;
}
.qty-input:focus { outline: none; }

/* Add Cart Button */
.btn-add-cart {
    flex: 1;
    height: 54px;
    border: none;
    background: var(--modal-accent);
    color: white;
    font-family: var(--modal-font-body);
    font-size: 1rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    border-radius: 8px; /* Matching radius */
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 20px rgba(116, 36, 41, 0.3);
}

.btn-add-cart:hover {
    background: #5a1a1f;
    transform: translateY(-2px);
    box-shadow: 0 12px 25px rgba(116, 36, 41, 0.4);
}

.btn-add-cart.disabled {
    background: #eaeaea;
    color: #999;
    box-shadow: none;
    cursor: not-allowed;
    transform: none;
}

/* Responsive Defaults */
@media (max-width: 900px) {
    .modal-content {
        height: 95vh;
        max-height: none;
        width: 100%;
        border-radius: 12px 12px 0 0;
        bottom: 0;
        transform: translateY(100%);
    }

    .product-modal.active .modal-content {
        transform: translateY(0);
    }
    
    .product-modal {
        align-items: flex-end; /* Slide up from bottom on mobile */
    }

    .modal-body {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
    }

    .modal-gallery-section {
        height: 300px;
        padding: 1rem;
        border-right: none;
        border-bottom: 1px solid var(--modal-border);
    }

    .details-scroll-container {
        padding: 1.5rem 1.5rem 80px 1.5rem;
    }
    
    .product-title {
        font-size: 2rem;
    }
    
    .modal-actions-footer {
        padding: 1rem 1.5rem;
    }
}

/* Responsive Mobile - FULL SCREEN */
@media (max-width: 768px) {
    .product-modal {
        display: block; /* Remove flex centering */
        padding: 0 !important;
    }

    .modal-content {
        position: absolute; /* Force it to cover everything */
        top: 0;
        left: 0;
        width: 100% !important;
        height: 100% !important;
        max-width: none !important;
        max-height: none !important;
        border-radius: 0 !important;
        margin: 0 !important;
        transform: none !important;
        display: flex;
        flex-direction: column;
        border: none !important;
        box-shadow: none !important;
    }
    
    .product-modal.active .modal-content {
        transform: none !important;
    }
    
    .modal-body {
        flex-direction: column;
        flex: 1;
        height: auto;
        overflow-y: auto; /* Body scrolls */
        display: flex;
        padding-bottom: 80px; /* Space for fixed footer */
    }
    
    /* Close button always visible on top */
    .modal-close {
        position: fixed; /* Fixed to viewport */
        top: 15px;
        right: 15px;
        z-index: 9999;
        background: rgba(255, 255, 255, 0.9);
        box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    }
    
    /* Gallery section - auto height to fit content */
    .modal-gallery-section {
        width: 100%;
        height: auto; /* Allow growth */
        min-height: 300px;
        flex-shrink: 0;
        padding: 20px 10px; /* More padding */
        border-right: none;
        border-bottom: 1px solid var(--modal-border);
        display: block; /* Ensure it behaves as block container */
    }
    
    .gallery-container {
        height: auto; /* Follow content */
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 15px;
    }
    
    .main-image {
        max-width: 60%; /* Smaller image on mobile to fit short desc */
        max-height: 250px; /* Cap height */
        margin-bottom: 10px;
    }
    
    .main-image {
        max-width: 80%;
        max-height: 90%;
    }
    
    /* Details section - flows below */
    .modal-details-section {
        width: 100%;
        height: auto;
        overflow: visible;
        flex-grow: 1;
        display: flex;
        flex-direction: column;
    }

    .details-top-section {
        padding: 1.5rem;
    }

    .details-scroll-body {
        padding: 0 1.5rem 1.5rem 1.5rem;
        overflow: visible; /* Let parent scroll */
    }
    
    /* Make typography slightly smaller for mobile */
    .product-title {
        font-size: 1.8rem;
    }
    
    .modal-price-container .price-value {
        font-size: 2.2rem;
    }
    
    /* Footer/Controls FIXED at bottom */
    .modal-actions-footer {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        background: #fff;
        padding: 15px 20px;
        border-top: 1px solid #eee;
        z-index: 100;
        box-shadow: 0 -5px 20px rgba(0,0,0,0.05);
        margin-top: 0;
        gap: 10px;
    }
    
    /* Adjust quantity selector for limited width */
    .quantity-control {
        width: 100px;
        height: 48px;
    }

    .btn-add-cart {
        height: 48px;
        font-size: 0.9rem;
    }
    
    /* Ensure content isn't hidden behind fixed footer */
    .product-full-desc {
        margin-bottom: 20px;
    }
}
