/**
 * Frontend Styles for Iam Alive Variations
 * Modern, optimized CSS for variation cards
 */

/* ===== Hide Default WooCommerce Variations (Swatchly Method) ===== */
/* The select elements are wrapped in .iav-default-select with inline display:none */
/* This ensures they stay in DOM for WooCommerce but are completely hidden */

.iav-default-select {
    display: none !important;
    position: absolute !important;
    left: -9999px !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

/* Hide the entire variations table - inline style is added for immediate hiding on load */
/* This CSS reinforces the hiding to prevent any FOUC */
.variations_form table.variations {
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    overflow: hidden !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
}

/* Hide variation price permanently (Woodmart wd-price-outside method) */
/* Main price at top will be updated by JavaScript */
.variations_form.iav-active .woocommerce-variation-price {
    display: none !important;
}

.variations_form.iav-active .woocommerce-variation-availability {
    display: none !important;
}

/* Hide sale badges on variable products when using our cards */
.product-type-variable .product-labels {
    display: none !important;
}

/* ===== Container ===== */
.iav-variations-wrapper {
    margin: 20px 0;
}

.iav-cards-container {
    width: 100%;
    margin: 0 auto;
}

/* ===== Grid System ===== */
.iav-cards-grid {
    display: grid;
    gap: 15px;
    margin: 20px 0;
}

/* Default: Desktop 5 columns (will be overridden by inline styles) */
@media (min-width: 769px) {
    .iav-cards-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}

/* Mobile: 2 columns (will be overridden by inline styles) */
@media (max-width: 768px) {
    .iav-cards-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
}

/* ===== Card Base ===== */
.iav-card {
    position: relative;
    background: #ffffff;
    border: 2px solid #e0e0e0;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* Height is now controlled by profile settings via dynamic CSS */
}

.iav-card:focus {
    outline: 2px solid #88c338;
    outline-offset: 2px;
}

/* ===== Card Inner ===== */
.iav-card-inner {
    padding: 20px 15px;
    position: relative;
    display: flex;
    flex-direction: column;
    flex: 1;
    justify-content: center;
    align-items: center;
}

@media (max-width: 768px) {
    /* Height is now controlled by profile settings via dynamic CSS */
    
    .iav-card-inner {
        padding: 15px 10px;
    }
}

/* ===== Card States ===== */
.iav-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.iav-card:active {
    transform: translateY(0);
}

.iav-card.iav-card-selected {
    border-color: #88c338;
    background: rgba(136, 195, 56, 0.08);
}

.iav-card.iav-card-disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* ===== Badges ===== */
.iav-card-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    z-index: 1;
}

.iav-badge-sale {
    background: #e74c3c;
    color: #ffffff;
}

.iav-badge-hot {
    background: #f39c12;
    color: #ffffff;
}

@media (max-width: 768px) {
    .iav-card-badge {
        padding: 3px 8px;
        font-size: 9px;
        top: 6px;
        right: 6px;
    }
}

/* ===== Card Content ===== */
.iav-card-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px; /* Reduced gap to fit better in fixed height */
    width: 100%;
}

/* ===== Card Image ===== */
.iav-card-image {
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0; /* Prevent shrinking */
}

.iav-card-image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 4px;
}

/* Image size variants */
.iav-cards-container[data-image-size="60"] .iav-card-image {
    width: 60px;
    height: 60px;
}

.iav-cards-container[data-image-size="100"] .iav-card-image {
    width: 100px;
    height: 100px;
}

@media (max-width: 768px) {
    .iav-card-image {
        width: 60px;
        height: 60px;
    }
    
    .iav-cards-container[data-image-size="100"] .iav-card-image {
        width: 80px;
        height: 80px;
    }
}

.iav-card-name {
    font-weight: 600;
    font-size: 15px;
    line-height: 1.4;
    color: #333333;
    text-align: center;
    word-break: break-word;
    hyphens: auto;
}

@media (max-width: 768px) {
    .iav-card-name {
        font-size: 13px;
    }
}

/* ===== Pricing ===== */
.iav-card-price {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.iav-price-regular {
    text-decoration: line-through;
    opacity: 0.6;
    font-size: 13px;
    color: #666666;
}

.iav-price-current {
    color: #88c338;
    font-size: 18px;
    font-weight: 700;
    line-height: 1.2;
}

@media (max-width: 768px) {
    .iav-price-regular {
        font-size: 11px;
    }
    
    .iav-price-current {
        font-size: 16px;
    }
}

/* Price formatting */
.iav-price-current .woocommerce-Price-amount,
.iav-price-regular .woocommerce-Price-amount {
    font-weight: inherit;
}

.iav-price-current .woocommerce-Price-currencySymbol {
    font-size: 0.85em;
    margin-left: 2px;
}

/* ===== Card Style Variants ===== */

/* Modern Style (default) */
.iav-card.modern {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.iav-card.modern:hover {
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
}

/* Minimal Style */
.iav-card.minimal {
    border: 1px solid #e0e0e0;
    box-shadow: none;
}

.iav-card.minimal:hover {
    border-color: #88c338;
    box-shadow: 0 2px 8px rgba(136, 195, 56, 0.15);
}

/* Bordered Style */
.iav-card.bordered {
    border: 2px solid #333333;
    box-shadow: none;
}

.iav-card.bordered:hover {
    border-color: #88c338;
}

/* ===== Loading State ===== */
.iav-card.iav-card-loading {
    pointer-events: none;
    opacity: 0.6;
}

.iav-card.iav-card-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #88c338;
    border-top-color: transparent;
    border-radius: 50%;
    animation: iav-spin 0.8s linear infinite;
}

@keyframes iav-spin {
    to { transform: rotate(360deg); }
}

/* ===== Accessibility ===== */
.iav-card:focus-visible {
    outline: 3px solid #88c338;
    outline-offset: 3px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .iav-card {
        border-width: 3px;
    }
    
    .iav-card.iav-card-selected {
        border-width: 4px;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .iav-card,
    .iav-card-inner,
    * {
        transition: none !important;
        animation: none !important;
    }
}

/* ===== Dark Mode Support (if theme supports) ===== */
@media (prefers-color-scheme: dark) {
    .iav-card {
        background: #2c2c2c;
        border-color: #444444;
    }
    
    .iav-card-name {
        color: #ffffff;
    }
    
    .iav-card.iav-card-selected {
        background: rgba(136, 195, 56, 0.15);
    }
}

/* ===== Print Styles ===== */
@media print {
    .iav-card {
        border: 1px solid #000;
        box-shadow: none !important;
        page-break-inside: avoid;
    }
    
    .iav-card-badge {
        background: #000 !important;
        color: #fff !important;
    }
}

