/**
 * Ecommerce Elementor Widgets - Frontend Styles
 */

/* General Widget Styles */
.eew-error {
    background: #f8d7da;
    color: #721c24;
    padding: 15px;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
    margin: 10px 0;
}

.eew-no-products {
    text-align: center;
    padding: 40px 20px;
    color: #666;
    font-style: italic;
}

/* Button Styles */
.eew-button {
    display: inline-block;
    padding: 10px 20px;
    background-color: #007cba;
    color: #ffffff;
    text-decoration: none;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    text-align: center;
    min-width: 120px;
}

.eew-button:hover {
    background-color: #005a87;
    color: #ffffff;
    text-decoration: none;
}

.eew-button:disabled,
.eew-button.disabled {
    background-color: #ccc;
    color: #666;
    cursor: not-allowed;
    opacity: 0.6;
}

/* Cart Count Widget */
.eew-cart-count-wrapper {
    display: inline-block;
}

.eew-cart-count {
    display: inline-block;
    position: relative;
    padding: 8px 16px;
    text-decoration: none;
    color: inherit;
    transition: all 0.3s ease;
}

.eew-cart-count:hover {
    text-decoration: none;
    color: inherit;
    opacity: 0.8;
}

.eew-cart-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #e74c3c;
    color: #fff;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    line-height: 20px;
    text-align: center;
    font-size: 12px;
    font-weight: bold;
    min-width: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Hide badge when cart is empty */
.eew-count-zero .eew-cart-badge {
    display: none;
}

/* Cart count icon wrapper */
.eew-cart-icon-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.eew-cart-icon {
    width: 24px;
    height: 24px;
    fill: currentColor;
    display: inline-block;
    vertical-align: middle;
}

.eew-cart-icon.eew-icon-before {
    margin-right: 5px;
}

.eew-cart-icon.eew-icon-after {
    margin-left: 5px;
}

.eew-cart-icon i {
    display: inline-block;
    vertical-align: inherit;
    font-style: normal;
    font-variant: normal;
    text-rendering: auto;
    line-height: 1;
}

/* Fallback for Font Awesome icons if Elementor styles don't load */
.eew-cart-icon .fas,
.eew-cart-icon .far,
.eew-cart-icon .fab {
    font-family: "Font Awesome 5 Free", "Font Awesome 5 Pro", "Font Awesome 6 Free", "Font Awesome 6 Pro";
    font-weight: 900;
}

.eew-cart-icon .far {
    font-weight: 400;
}

.eew-cart-icon img {
    max-width: 100%;
    height: auto;
    vertical-align: inherit;
}

.eew-cart-text {
    font-size: inherit;
    font-weight: inherit;
}

/* Cart count position variations */
.eew-cart-count-position-top-left .eew-cart-badge {
    top: -8px;
    left: -8px;
    right: auto;
}

.eew-cart-count-position-bottom-right .eew-cart-badge {
    top: auto;
    bottom: -8px;
    right: -8px;
}

.eew-cart-count-position-bottom-left .eew-cart-badge {
    top: auto;
    bottom: -8px;
    left: -8px;
    right: auto;
}

.eew-cart-count-position-inline .eew-cart-badge {
    position: static;
    margin-left: 8px;
    top: auto;
    right: auto;
    border-radius: 12px;
    padding: 2px 8px;
    background: #3498db;
}

/* Add to Cart Widget */
.eew-add-to-cart-wrapper {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
}

.eew-cart-form {
    display: flex;
    align-items: center;
    gap: 10px;
}

.eew-quantity-input {
    width: 80px;
    height: 40px;
    padding: 5px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    text-align: center;
    font-size: 14px;
}

/* Price Styles */
.eew-price {
    font-weight: bold;
    margin: 5px 0;
}

.eew-price-regular {
    color: #333;
    font-size: 16px;
}

.eew-price-sale {
    color: #e74c3c;
    font-size: 16px;
    margin-left: 5px;
}

.eew-price-original {
    color: #999;
    text-decoration: line-through;
    font-size: 14px;
    margin-right: 5px;
}

/* Stock Status */
.eew-stock-status {
    padding: 4px 8px;
    border-radius: 3px;
    font-size: 12px;
    font-weight: bold;
    text-transform: uppercase;
    display: inline-block;
    margin: 5px 0;
}

/* Product Grid */
.eew-product-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin: 0;
    padding: 0;
}

.eew-product-card {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s ease;
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.eew-product-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.eew-product-image-wrap {
    position: relative;
    overflow: hidden;
    background: #f8f8f8;
    aspect-ratio: 1;
}

.eew-product-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.eew-product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.eew-product-card:hover .eew-product-image img {
    transform: scale(1.05);
}

.eew-no-image {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f0f0f0;
    color: #ccc;
    font-size: 48px;
}

.eew-product-content {
    padding: 15px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.eew-product-title {
    margin: 0 0 8px 0;
    font-size: 16px;
    line-height: 1.3;
}

.eew-product-title a {
    color: #333;
    text-decoration: none;
    transition: color 0.3s ease;
}

.eew-product-title a:hover {
    color: #007cba;
    text-decoration: none;
}

.eew-product-excerpt {
    color: #666;
    font-size: 14px;
    line-height: 1.4;
    margin: 5px 0;
    flex-grow: 1;
}

.eew-product-actions {
    margin-top: auto;
    padding-top: 10px;
}

.eew-sale-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    background: #e74c3c;
    color: #fff;
    padding: 4px 8px;
    border-radius: 3px;
    font-size: 12px;
    font-weight: bold;
    text-transform: uppercase;
    z-index: 2;
}

/* Product Carousel */
.eew-product-carousel-wrapper {
    position: relative;
}

.eew-product-carousel {
    overflow: hidden;
}

.eew-product-carousel .swiper-slide {
    height: auto;
}

/* Swiper Navigation */
.eew-product-carousel .swiper-button-next,
.eew-product-carousel .swiper-button-prev {
    width: 40px;
    height: 40px;
    margin-top: -20px;
    color: #333;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.eew-product-carousel .swiper-button-next:after,
.eew-product-carousel .swiper-button-prev:after {
    font-size: 16px;
    font-weight: bold;
}

.eew-product-carousel .swiper-button-next:hover,
.eew-product-carousel .swiper-button-prev:hover {
    background: rgba(255, 255, 255, 1);
    transform: scale(1.1);
}

/* Swiper Pagination */
.eew-product-carousel .swiper-pagination {
    position: relative;
    bottom: auto;
    margin-top: 20px;
}

.eew-product-carousel .swiper-pagination-top {
    margin-bottom: 20px;
    margin-top: 0;
}

.eew-product-carousel .swiper-pagination-bullet {
    width: 8px;
    height: 8px;
    background: #ccc;
    opacity: 1;
    transition: all 0.3s ease;
}

.eew-product-carousel .swiper-pagination-bullet-active {
    background: #333;
    transform: scale(1.2);
}

/* Responsive Styles */
@media (max-width: 1024px) {
    .eew-product-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 15px;
    }
}

@media (max-width: 768px) {
    .eew-product-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
    
    .eew-cart-form {
        flex-direction: column;
        align-items: stretch;
    }
    
    .eew-quantity-input {
        width: 100%;
    }
    
    .eew-product-card {
        margin-bottom: 15px;
    }
    
    .eew-product-content {
        padding: 12px;
    }
    
    /* Cart count responsive styles */
    .eew-cart-icon {
        width: 20px;
        height: 20px;
    }
    
    .eew-cart-badge {
        width: 18px;
        height: 18px;
        line-height: 18px;
        font-size: 11px;
        top: -6px;
        right: -6px;
    }
}

@media (max-width: 480px) {
    .eew-product-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .eew-add-to-cart-wrapper {
        text-align: center;
    }
    
    .eew-cart-form {
        justify-content: center;
    }
    
    /* Cart count small screen styles */
    .eew-cart-count {
        padding: 6px 12px;
    }
    
    .eew-cart-icon {
        width: 18px;
        height: 18px;
    }
    
    .eew-cart-badge {
        width: 16px;
        height: 16px;
        line-height: 16px;
        font-size: 10px;
        top: -5px;
        right: -5px;
        min-width: 16px;
    }
    
    .eew-product-carousel .swiper-button-next,
    .eew-product-carousel .swiper-button-prev {
        width: 35px;
        height: 35px;
        margin-top: -17.5px;
    }
    
    .eew-product-carousel .swiper-button-next:after,
    .eew-product-carousel .swiper-button-prev:after {
        font-size: 14px;
    }
}

/* Admin Styles */
.elementor-editor-active .eew-product-grid {
    min-height: 200px;
}

.elementor-editor-active .eew-product-carousel {
    min-height: 200px;
}

/* Loading States */
.eew-loading {
    opacity: 0.6;
    pointer-events: none;
}

.eew-button.loading {
    position: relative;
    color: transparent;
}

.eew-button.loading:after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border: 2px solid #fff;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 1s linear infinite;
}

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

/* Cart animation */
@keyframes addToCart {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
    }
}

.eew-add-to-cart-btn.adding {
    animation: addToCart 0.3s ease;
}

/* Success/Error Messages */
.eew-message {
    padding: 10px 15px;
    border-radius: 4px;
    margin: 10px 0;
    font-size: 14px;
}

.eew-message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.eew-message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .eew-product-card {
        background: #2a2a2a;
        border-color: #444;
        color: #fff;
    }
    
    .eew-product-title a {
        color: #fff;
    }
    
    .eew-product-title a:hover {
        color: #4fc3f7;
    }
    
    .eew-product-excerpt {
        color: #ccc;
    }
    
    .eew-no-image {
        background: #333;
        color: #666;
    }
}
