/**
 * Lightweight VAT Plugin Styles
 * Modern, accessible CSS for VAT price display with enhanced UX
 */

/*
 * Plugin color system - CSS variables are now dynamically generated from admin settings
 * Default fallbacks are provided but will be overridden by inline styles
 */
:root {
    /* Fallback values in case dynamic CSS fails to load */
    --lvp-color-primary: #94be57;
    --lvp-color-secondary: #ff691f;
    --lvp-color-text: #222222;
    --lvp-color-text-muted: #6a6a6a;
    --lvp-color-heading: #252525;
    --lvp-surface: #ffffff;
    --lvp-border: #e6e6e6;
    --lvp-btn-bg: #94be57;
    --lvp-btn-text: #000000;
    --lvp-btn-border: #7cab45;
    --lvp-btn-bg-hover: #7cab45;
    --lvp-btn-text-hover: #000000;
}


/* VAT Price Suffixes - Enhanced */
.vat-price {
    font-size: 0.85em;
    color: #666;
    font-weight: 500;
    display: inline-block;
    margin-left: 0.3em;
    transition: all 0.2s ease;
    border-radius: 3px;
    line-height: 1.2;
}

/* Ensure VAT suffix displays correctly on sale prices - prevent font-size: 0 inheritance */
.price ins + .vat-price,
.price .woocommerce-Price-amount + .vat-price,
ins + .vat-price,
del + ins + .vat-price {
    font-size: 0.85rem !important;
    min-width: 1px !important;
    min-height: 1px !important;
}

.vat-price.vat-exempt {
    color: #666;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.vat-price.vat-exempt::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    transition: left 0.5s;
}

.vat-price.vat-exempt:hover::before {
    left: 100%;
}

.vat-price.vat-exempt:hover {
    text-decoration: none;
}

.woobt-price-ori .price .vat-price.vat-exempt{
    display: none !important;
}

.woobt-price-ori span.priceFromLbl {
    margin: 0;
    padding: 0;
    display: block;
}

.woobt-title {
    max-width: 55%;
}

.woobt-product .woobt-price, .woobt-product .woobt-price .price{
    margin-right: 8px;
}

.vat-price.vat-zero {
    color: #666;
}

.vat-price.vat-standard {
    color: #666;
}

/* Alternative Price Display - Enhanced */
.alternative-price {
    display: block;
    color: #6c757d;
    font-size: 0.9em;
    margin-top: 8px;
    line-height: 1.4;
    padding: 8px 12px;
    transition: all 0.3s ease;
    position: relative;
}

/* Inline Alternative Price for Shop/Category Pages */
.alternative-price-inline {
    display: block !important;
    color: #6c757d;
    font-size: 0.8em;
    /* margin-top: 4px; */
    line-height: 1.3;
}

.alt-price-label {
    font-size: 0.65em;
    margin-left: 0.6em;
    opacity: 0.7;
    text-transform: none;
    letter-spacing: normal;
    font-weight: 500;
}

.alt-price-value {
    font-weight: 600;
    color: #495057;
}

.alt-price-value bdi {
    font-size: .8em;
    color: #575757;
}

.alt-price-loading {
    font-style: italic;
    color: #6c757d;
    font-size: 0.9em;
}

/* VAT Exempt Modal - Enhanced */
.vat-modal {
    display: none;
    position: fixed;
    z-index: 999999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0.6));
    backdrop-filter: blur(5px);
    animation: fadeIn 0.4s ease-in-out;
    /* Ensure centered even before .show is applied to avoid top-left flash */
    align-items: center;
    justify-content: center;
}

.vat-modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.vat-modal-content {
    background: var(--lvp-surface);
    margin: 0;
    padding: 40px;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    width: 90%;
    max-width: 550px;
    position: relative;
    animation: slideIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    border: 1px solid var(--lvp-border);
    color: var(--lvp-color-text);
}

.vat-modal-close {
    color: #6c757d;
    position: absolute;
    right: 20px;
    top: 20px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(108, 117, 125, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 18px;
    font-weight: bold;
    border: none;
    z-index: 2;
    padding: unset;
}

.vat-modal-close:hover,
.vat-modal-close:focus {
    color: #dc3545;
    background: rgba(220, 53, 69, 0.1);
    transform: rotate(90deg) scale(1.1);
    outline: 2px solid #dc3545;
    outline-offset: 2px;
}

.vat-modal h2 {
    color: var(--lvp-color-heading);
    margin: 0 0 25px 0;
    font-size: 1.6em;
    font-weight: 700;
    text-align: center;
    position: relative;
    padding-bottom: 15px;
}

.vat-modal h2::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 3px;
    background: var(--lvp-color-secondary);
    border-radius: 2px;
}

.vat-modal p {
    color: var(--lvp-color-text);
    line-height: 1.7;
    margin-bottom: 18px;
    font-size: 1.05em;
}

.vat-modal-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--lvp-btn-bg);
    color: var(--lvp-btn-text);
    padding: 14px 28px;
    text-decoration: none;
    border-radius: 8px;
    margin-top: 20px;
    transition: all 0.3s ease;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    position: relative;
    overflow: hidden;
    border: 1px solid var(--lvp-btn-border);
}

.vat-modal-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.vat-modal-button:hover::before {
    left: 100%;
}

.vat-modal-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    background: var(--lvp-btn-bg-hover);
    color: var(--lvp-btn-text-hover);
    text-decoration: none;
}

.vat-modal-button:focus {
    outline: 2px solid var(--lvp-color-primary);
    outline-offset: 2px;
}

/* Enhanced Animations */
@keyframes fadeIn {
    from { 
        opacity: 0;
        backdrop-filter: blur(0px);
    }
    to { 
        opacity: 1;
        backdrop-filter: blur(5px);
    }
}

@keyframes slideIn {
    from { 
        opacity: 0;
        transform: translateY(-30px) scale(0.95);
    }
    to { 
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

@keyframes shimmer {
    0% { background-position: -200px 0; }
    100% { background-position: calc(200px + 100%) 0; }
}

/* Enhanced Responsive Design */
@media (max-width: 768px) {
    .vat-modal-content {
        margin: 0;
        padding: 30px 20px;
        width: 95%;
        border-radius: 12px;
    }
    
    .alternative-price {
        font-size: 0.85em;
        padding: 6px 10px;
        margin-top: 6px;
    }
    
    .vat-price {
        font-size: 0.75em;
        padding: 1px 4px;
        margin-left: 0.3em;
    }
    
    .vat-modal h2 {
        font-size: 1.25em;
    }
    
    .vat-modal-button {
        width: 100%;
        justify-content: center;
        padding: 16px 20px;
    }

    /* Convert close icon to 'Dismiss' button on its own line */
    .vat-modal-close {
        position: static;
        display: inline-flex;
        width: auto;
        height: auto;
        padding: 8px 12px;
        margin: -6px 0 10px 0; /* pull up slightly to be closer to top edge */
        border-radius: 6px;
        background: transparent;
        border: 1px solid var(--lvp-border);
        font-size: 0; /* hide the × character */
        transform: none !important; /* prevent rotation on hover */
        float: right; /* right-align on its own line */
    }
    .vat-modal-close::after {
        content: 'Dismiss';
        font-size: 0.95rem;
        font-weight: 600;
        color: var(--lvp-color-text);
        line-height: 1.2;
    }
    .vat-modal-close:hover,
    .vat-modal-close:focus {
        background: rgba(0,0,0,0.04);
        outline: 2px solid var(--lvp-border);
        outline-offset: 2px;
    }
}

@media (max-width: 480px) {
    .vat-price {
        display: block;
        margin: 4px 0 0 0;
        text-align: left;
    }
    
    .alternative-price {
        font-size: 0.8em;
    }
}

/* Enhanced WooCommerce Integration */
.woocommerce .price .vat-price {
    display: inline-block;
    vertical-align: middle;
}

.woocommerce-variation-price .vat-price {
    display: inline-block;
    vertical-align: middle;
}

.woocommerce-Price-amount + .vat-price {
    margin-left: 0.4em;
}

/* Product page enhancements */
.single-product .price .vat-price {
    font-size: 0.9em;
}

.woocommerce-loop-product__title + .price .vat-price {
    font-size: 0.8em;
}

/* Cart and checkout styling */
.woocommerce-cart .vat-price,
.woocommerce-checkout .vat-price {
    font-size: 0.8em;
    margin-left: 0.3em;
}

/* Variable product styling */
.variations .vat-price {
    font-size: 0.8em;
}

/* Legacy Admin Styles (for compatibility) */
.vat-admin-section {
    background: #fff;
    border: 1px solid #e1e5e9;
    padding: 25px;
    margin: 20px 0;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.vat-admin-section h2 {
    margin-top: 0;
    color: #2c3e50;
    font-weight: 600;
}

.vat-admin-section .button {
    margin-right: 12px;
    border-radius: 6px;
    transition: all 0.3s ease;
}

.vat-admin-section .button:hover {
    transform: translateY(-1px);
}

/* Screen reader only content */
.vat-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .vat-price {
        background: transparent;
        border: 2px solid currentColor;
        color: inherit;
    }
    
    .alternative-price {
        background: transparent;
        border: 1px solid currentColor;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .vat-price,
    .alternative-price,
    .vat-modal,
    .vat-modal-content,
    .vat-modal-button {
        animation: none;
        transition: none;
    }
    
    .vat-price.vat-exempt:hover,
    .vat-modal-button:hover {
        transform: none;
    }
}

/* Single Product: Minimal style overrides (remove boxes around suffix and alt prices) */
.single-product .summary .price .vat-price,
.single-product .summary .woocommerce-variation-price .price .vat-price {
    background: none !important;
    padding: 0 !important;
    border: 0 !important;
    box-shadow: none !important;
}

/* VAT Exempt specific styling on single product pages */
.single-product .summary .price .vat-price.vat-exempt,
.single-product .summary .woocommerce-variation-price .price .vat-price.vat-exempt {
    color: #666 !important;
    font-size: 0.6em !important;
}

/* Override Minimog theme styles that interfere with VAT elements */
.minimog-product .price .vat-price,
.minimog-product .price .alternative-price {
    font-size: 0.85em !important;
    display: inline-block !important;
    vertical-align: middle !important;
}

.minimog-product .price .vat-price.vat-exempt {
    font-size: 0.6em !important;
    color: #666 !important;
}

.minimog-product .price .vat-price.vat-zero,
.minimog-product .price .vat-price.vat-standard {
    font-size: 0.85em !important;
    color: #333 !important;
}

.minimog-product .price .alternative-price {
    font-size: 0.9em !important;
    margin-top: 8px !important;
    display: block !important;
}

/* Additional overrides for homepage product loops and other contexts */
.woocommerce .price .vat-price,
.woocommerce-page .price .vat-price,
.products .price .vat-price,
.product .price .vat-price {
    font-size: 0.85em !important;
    display: inline-block !important;
    vertical-align: middle !important;
    color: #333 !important;
}

.woocommerce .price .vat-price.vat-exempt,
.woocommerce-page .price .vat-price.vat-exempt,
.products .price .vat-price.vat-exempt,
.product .price .vat-price.vat-exempt {
    font-size: 0.85em !important;
    color: #333 !important;
}

/* Ensure VAT elements show on homepage product grids */
.home .price .vat-price,
.front-page .price .vat-price {
    font-size: 0.85em !important;
    display: inline-block !important;
    color: #333 !important;
}

.home .price .vat-price.vat-exempt,
.front-page .price .vat-price.vat-exempt {
    font-size: 0.85em !important;
    color: #333 !important;
}

/* Remove shimmer overlay on exempt badge within single product pages */
.single-product .summary .price .vat-price.vat-exempt::before,
.single-product .summary .woocommerce-variation-price .price .vat-price.vat-exempt::before {
    content: none !important;
}


.single-product .summary .price .vat-price.vat-exempt:hover,
.single-product .summary .woocommerce-variation-price .price .vat-price.vat-exempt:hover {
    transform: none;
    box-shadow: none;
}

/* Alternative price: remove box styling on single product */
.single-product .summary .alternative-price {
    background: none !important;
    border: 0 !important;
    padding: 0 !important;
    margin-top: 6px;
}

/* Tweak label color to inherit theme text color on single product */
.single-product .summary .alt-price-label {
    color: inherit;
}

/* Hide alternative price for zero-rated products */
.alternative-price.vat-status-zero,
.alternative-price-inline.vat-status-zero {
    display: none !important;
}
