/**
 * WC Energy Labels Pro - Frontend Styles
 * Version: 2.0.0
 */

/* ==========================================================================
   Energy Label Container
   ========================================================================== */

.wc-energy-label-pro {
    margin: 15px 0;
    text-align: center;
    clear: both;
    position: relative;
}

.wc-energy-label-pro.align-left {
    text-align: left;
}

.wc-energy-label-pro.align-right {
    text-align: right;
}

.wc-energy-label-pro.align-center {
    text-align: center;
}

/* ==========================================================================
   Energy Label Wrapper
   ========================================================================== */

.energy-label-wrapper {
    display: inline-block;
    position: relative;
    text-align: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.energy-label-wrapper:hover {
    transform: translateY(-2px);
}

/* ==========================================================================
   Energy Label Image
   ========================================================================== */

.energy-label-image {
    display: block;
    margin: 0 auto 10px;
    border-radius: 4px;
    transition: opacity 0.3s ease, transform 0.2s ease;
    cursor: pointer;
    max-width: 100%;
    height: auto;
}

.energy-label-image:hover {
    transform: scale(1.02);
    opacity: 0.95;
}

.energy-label-image.lazy {
    opacity: 0;
    background: #f5f5f5;
    min-height: 100px;
}

.energy-label-image.loaded {
    animation: fadeIn 0.3s ease;
}

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

.energy-label-image.error {
    background: #fff url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100"><text x="50%" y="50%" text-anchor="middle" dy=".3em" fill="%23999">Error</text></svg>') center no-repeat;
    border: 1px solid #ddd;
}

/* ==========================================================================
   Energy Label Text
   ========================================================================== */

.energy-label-text {
    display: block;
    font-size: 14px;
    color: #666;
    margin-top: 5px;
    text-align: center;
    line-height: 1.4;
}

.energy-label-text-value {
    font-weight: 600;
    color: #333;
}

/* ==========================================================================
   No Energy Label
   ========================================================================== */

.no-energy-label {
    padding: 10px;
    background: #f9f9f9;
    border: 1px dashed #ddd;
    border-radius: 4px;
    color: #999;
    font-style: italic;
    font-size: 13px;
}

/* ==========================================================================
   Energy Badge (Catalog)
   ========================================================================== */

.wc-energy-label-catalog {
    margin: 5px 0;
    text-align: center;
}

.energy-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 3px;
    font-weight: bold;
    font-size: 11px;
    text-transform: uppercase;
    color: white;
    letter-spacing: 0.5px;
    transition: transform 0.2s ease;
}

.energy-badge:hover {
    transform: scale(1.05);
}

/* Badge colors */
.energy-badge-a { 
    background: #00a652; 
    box-shadow: 0 2px 4px rgba(0, 166, 82, 0.3);
}

.energy-badge-b { 
    background: #51b748;
    box-shadow: 0 2px 4px rgba(81, 183, 72, 0.3);
}

.energy-badge-c { 
    background: #bfd730; 
    color: #333;
    box-shadow: 0 2px 4px rgba(191, 215, 48, 0.3);
}

.energy-badge-d { 
    background: #fff100; 
    color: #333;
    box-shadow: 0 2px 4px rgba(255, 241, 0, 0.3);
}

.energy-badge-e { 
    background: #fdb913;
    box-shadow: 0 2px 4px rgba(253, 185, 19, 0.3);
}

.energy-badge-f { 
    background: #f37021;
    box-shadow: 0 2px 4px rgba(243, 112, 33, 0.3);
}

.energy-badge-g { 
    background: #ed1c24;
    box-shadow: 0 2px 4px rgba(237, 28, 36, 0.3);
}

/* Badge sizes */
.badge-small {
    font-size: 10px;
    padding: 2px 6px;
}

.badge-normal {
    font-size: 11px;
    padding: 3px 8px;
}

.badge-large {
    font-size: 13px;
    padding: 4px 10px;
}

/* Badge styles */
.badge-style-circle {
    border-radius: 50%;
    width: 30px;
    height: 30px;
    line-height: 30px;
    padding: 0;
    text-align: center;
}

.badge-style-square {
    border-radius: 0;
}

/* ==========================================================================
   Energy Consumption Display
   ========================================================================== */

.energy-consumption-wrapper {
    margin: 10px 0;
    font-size: 14px;
    color: #666;
}

.consumption-value {
    font-weight: bold;
    color: #333;
    font-size: 16px;
}

.consumption-annual {
    display: inline-block;
    padding: 5px 10px;
    background: #f5f5f5;
    border-radius: 3px;
}

.consumption-full {
    line-height: 1.5;
}

/* ==========================================================================
   Tooltip
   ========================================================================== */

.energy-label-tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 10px;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    font-size: 12px;
    line-height: 1.4;
    border-radius: 4px;
    white-space: nowrap;
    z-index: 1000;
    display: none;
    pointer-events: none;
}

.energy-label-tooltip:after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: rgba(0, 0, 0, 0.9) transparent transparent transparent;
}

/* ==========================================================================
   Lightbox
   ========================================================================== */

.energy-label-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.energy-label-lightbox.active {
    opacity: 1;
}

.lightbox-content {
    position: relative;
    max-width: 90%;
    max-height: 90%;
    text-align: center;
}

.lightbox-content img {
    max-width: 100%;
    max-height: 80vh;
    height: auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.lightbox-close {
    position: absolute;
    top: -40px;
    right: -40px;
    width: 40px;
    height: 40px;
    line-height: 40px;
    text-align: center;
    font-size: 30px;
    color: white;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.lightbox-close:hover {
    transform: rotate(90deg);
}

.lightbox-caption {
    margin-top: 20px;
    color: white;
    font-size: 14px;
}

/* ==========================================================================
   Products Grid
   ========================================================================== */

.wc-energy-products-grid {
    margin: 20px 0;
}

.wc-energy-products-grid ul.products {
    display: grid;
    gap: 20px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.wc-energy-products-grid.columns-2 ul.products {
    grid-template-columns: repeat(2, 1fr);
}

.wc-energy-products-grid.columns-3 ul.products {
    grid-template-columns: repeat(3, 1fr);
}

.wc-energy-products-grid.columns-4 ul.products {
    grid-template-columns: repeat(4, 1fr);
}

.wc-energy-products-grid.columns-5 ul.products {
    grid-template-columns: repeat(5, 1fr);
}

.wc-energy-products-grid.columns-6 ul.products {
    grid-template-columns: repeat(6, 1fr);
}

.energy-label-badge-grid {
    margin: 10px 0;
}

/* ==========================================================================
   Position Specific Styles
   ========================================================================== */

.wc-energy-label-pro.position-before_summary {
    margin-bottom: 20px;
}

.wc-energy-label-pro.position-after_summary {
    margin-top: 20px;
}

.wc-energy-label-pro.position-after_tabs {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

/* ==========================================================================
   WooCommerce Integration
   ========================================================================== */

/* Single product page */
.single-product .wc-energy-label-pro {
    margin: 20px 0;
}

/* Product loop */
.woocommerce ul.products li.product .wc-energy-label-catalog {
    margin: 8px 0;
}

/* Variations */
.variations_form .wc-energy-label-pro {
    margin-top: 15px;
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */

@media screen and (max-width: 768px) {
    .energy-label-image {
        max-width: 100px !important;
        width: 100px !important;
    }
    
    .wc-energy-products-grid.columns-4 ul.products,
    .wc-energy-products-grid.columns-5 ul.products,
    .wc-energy-products-grid.columns-6 ul.products {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .energy-label-tooltip {
        font-size: 11px;
        padding: 6px 10px;
    }
}

@media screen and (max-width: 480px) {
    .wc-energy-products-grid ul.products {
        grid-template-columns: 1fr;
    }
    
    .energy-badge {
        font-size: 10px;
        padding: 2px 6px;
    }
    
    .lightbox-close {
        top: 10px;
        right: 10px;
    }
}

/* ==========================================================================
   Print Styles
   ========================================================================== */

@media print {
    .energy-label-wrapper {
        page-break-inside: avoid;
    }
    
    .energy-label-image {
        max-width: 150px !important;
    }
    
    .energy-label-tooltip,
    .lightbox-close {
        display: none !important;
    }
}

/* ==========================================================================
   Accessibility
   ========================================================================== */

.wc-energy-label-pro:focus-within {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

.energy-label-image:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* Screen reader text */
.screen-reader-text {
    position: absolute !important;
    clip: rect(1px, 1px, 1px, 1px);
    padding: 0 !important;
    border: 0 !important;
    height: 1px !important;
    width: 1px !important;
    overflow: hidden;
}

/* ==========================================================================
   Dark Mode Support
   ========================================================================== */

@media (prefers-color-scheme: dark) {
    .wc-energy-label-pro {
        color: #ccc;
    }
    
    .energy-label-text {
        color: #aaa;
    }
    
    .no-energy-label {
        background: #2c2c2c;
        border-color: #444;
        color: #888;
    }
    
    .energy-consumption-wrapper {
        color: #aaa;
    }
    
    .consumption-annual {
        background: #2c2c2c;
        color: #ccc;
    }
}