/**
 * Quick View Modal Styles
 * Complements Tailwind classes for modal functionality
 *
 * @package Grabit
 * @version 1.0
 */

/* Modal Base - Full Screen Fixed Overlay */
.cc-qv-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    z-index: 9999;
    animation: qvFadeIn 0.2s ease-out;
}

.cc-qv-modal.flex {
    display: flex !important;
    align-items: center;
    justify-content: center;
}

/* Backdrop - Full Screen Dark Overlay */
.cc-qv-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    animation: qvBackdropIn 0.3s ease-out;
}

/* Panel - Centered White Box */
.cc-qv-panel {
    position: relative;
    z-index: 10;
    margin: 1rem auto;
    width: 95%;
    max-width: 1200px;
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    animation: qvSlideUp 0.3s ease-out;
}

/* Scrollbar Styling */
.cc-qv-panel::-webkit-scrollbar {
    width: 8px;
}

.cc-qv-panel::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.cc-qv-panel::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 10px;
}

.cc-qv-panel::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Close Button - Fixed Top Right */
.cc-qv-panel [data-qv-close],
.cc-qv-panel button[data-qv-close] {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 20;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #e5e7eb;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.cc-qv-panel [data-qv-close]:hover,
.cc-qv-panel button[data-qv-close]:hover {
    background: #ef4444;
    border-color: #ef4444;
    color: #fff;
    transform: rotate(90deg) scale(1.1);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
}

/* Thumbnail Active State */
.qv-thumb {
    cursor: pointer;
    transition: all 0.2s ease;
}

.qv-thumb:hover {
    transform: scale(1.05);
}

/* WooCommerce Variations in Modal */
.cc-qv-modal .variations_form table.variations {
    margin-bottom: 1rem;
}

.cc-qv-modal .variations_form table.variations td {
    padding: 0.5rem 0;
}

.cc-qv-modal .variations_form table.variations select {
    width: 100%;
    padding: 0.5rem 1rem;
    border: 1px solid #eee;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    color: #4b5966;
    background-color: #fff;
    transition: all 0.2s ease;
}

.cc-qv-modal .variations_form table.variations select:hover {
    border-color: #5caf90;
}

.cc-qv-modal .variations_form table.variations select:focus {
    outline: none;
    border-color: #5caf90;
    box-shadow: 0 0 0 3px rgba(92, 175, 144, 0.1);
}

.cc-qv-modal .variations_form .reset_variations {
    display: inline-block;
    margin-top: 0.5rem;
    font-size: 0.875rem;
    color: #999;
    text-decoration: underline;
    cursor: pointer;
}

.cc-qv-modal .variations_form .reset_variations:hover {
    color: #5caf90;
}

/* Quantity Controls in Modal */
.cc-qv-modal .quantity {
    display: inline-flex;
    align-items: center;
    border: 1px solid #eee;
    border-radius: 0.375rem;
    overflow: hidden;
}

.cc-qv-modal .quantity .qty-btn {
    width: 36px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-center;
    background: #f8f8fb;
    border: none;
    color: #4b5966;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 18px;
    font-weight: 500;
}

.cc-qv-modal .quantity .qty-btn:hover {
    background: #5caf90;
    color: #fff;
}

.cc-qv-modal .quantity input.qty {
    width: 60px;
    height: 40px;
    border: none;
    border-left: 1px solid #eee;
    border-right: 1px solid #eee;
    text-align: center;
    font-size: 14px;
    color: #4b5966;
    outline: none;
}

/* Add to Cart Button in Modal */
.cc-qv-modal .single_add_to_cart_button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 2rem;
    background: #4b5966;
    color: #fff;
    border: none;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 180px;
}

.cc-qv-modal .single_add_to_cart_button:hover {
    background: #5caf90;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(92, 175, 144, 0.3);
}

.cc-qv-modal .single_add_to_cart_button:active {
    transform: translateY(0);
}

.cc-qv-modal .single_add_to_cart_button.loading {
    opacity: 0.6;
    pointer-events: none;
}

.cc-qv-modal .single_add_to_cart_button.loading:after {
    content: '';
    width: 16px;
    height: 16px;
    margin-left: 8px;
    border: 2px solid #fff;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 0.6s linear infinite;
}

.cc-qv-modal .single_add_to_cart_button.disabled,
.cc-qv-modal .single_add_to_cart_button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Out of Stock */
.cc-qv-modal .stock.out-of-stock {
    color: #dc3545;
    font-weight: 500;
}

/* Variable Product Price */
.cc-qv-modal .woocommerce-variation-price {
    margin-top: 1rem;
}

.cc-qv-modal .woocommerce-variation-price .price {
    font-size: 1.5rem;
    font-weight: 700;
    color: #4b5966;
}

/* Animations */
@keyframes qvFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes qvBackdropIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes qvSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .cc-qv-modal {
        padding: 0;
    }
    
    .cc-qv-panel {
        margin: 0.5rem;
        width: calc(100% - 1rem);
        max-height: calc(100vh - 1rem);
        padding: 1.5rem;
        border-radius: 12px;
    }
    
    .cc-qv-panel [data-qv-close],
    .cc-qv-panel button[data-qv-close] {
        top: 0.5rem;
        right: 0.5rem;
        width: 36px;
        height: 36px;
    }
    
    .cc-qv-modal .grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .cc-qv-modal .single_add_to_cart_button {
        width: 100%;
    }
}

/* Ensure modal is always on top and full screen */
.cc-qv-modal.hidden {
    pointer-events: none !important;
}

/* Prevent body scroll when modal is open */
body.modal-open {
    overflow: hidden !important;
}

/* Accessibility: Focus Styles */
.cc-qv-modal *:focus {
    outline: 2px solid #5caf90;
    outline-offset: 2px;
}

.cc-qv-modal *:focus:not(:focus-visible) {
    outline: none;
}

.cc-qv-modal *:focus-visible {
    outline: 2px solid #5caf90;
    outline-offset: 2px;
}

/* Loading State for Images */
.qv-main-image img {
    transition: opacity 0.2s ease;
}

.qv-main-image img.loading {
    opacity: 0.5;
}

/* Custom Select Dropdown Arrow */
.cc-qv-modal .variations_form table.variations select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%234b5966' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    padding-right: 2.5rem;
}

/* Product Meta Links */
.cc-qv-summary a {
    transition: color 0.2s ease;
}

.cc-qv-summary a:hover {
    color: #5caf90;
}

/* Sale Badge in Modal (if needed) */
.cc-qv-modal .onsale {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: #dc3545;
    color: #fff;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    border-radius: 0.25rem;
    margin-bottom: 0.5rem;
}

/* Variation Description */
.cc-qv-modal .woocommerce-variation-description {
    margin-top: 1rem;
    padding: 1rem;
    background: #f8f8fb;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    color: #777;
}

/* Sticky Summary (optional, for tall content) */
@media (min-width: 768px) {
    .cc-qv-summary {
        max-height: calc(90vh - 4rem);
        overflow-y: auto;
    }
}

