/**
 * WC Smart Upsell - Frontend Styles
 *
 * @package WC_Smart_Upsell
 */

/* ==========================================================================
   Modal Styles
   ========================================================================== */

.wc-smart-upsell-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wc-smart-upsell-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(2px);
}

.wc-smart-upsell-modal-content {
    position: relative;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    width: 95%;
    max-width: 500px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: wcSmartUpsellModalIn 0.3s ease-out;
}

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

.wc-smart-upsell-modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid #eee;
    background: #f8f9fa;
}

.wc-smart-upsell-modal-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.wc-smart-upsell-modal-body {
    padding: 20px 24px;
    overflow-y: auto;
    flex: 1;
}

.wc-smart-upsell-modal-footer {
    padding: 16px 24px;
    border-top: 1px solid #eee;
    background: #f8f9fa;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Loading Spinner */
.wc-smart-upsell-modal-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px;
}

.wc-smart-upsell-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #0073aa;
    border-radius: 50%;
    animation: wcSmartUpsellSpin 0.8s linear infinite;
}

@keyframes wcSmartUpsellSpin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Product Card in Modal */
.wc-smart-upsell-product {
    display: flex;
    gap: 16px;
    padding: 16px;
    margin-bottom: 12px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background: #fff;
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.wc-smart-upsell-product:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border-color: #0073aa;
}

.wc-smart-upsell-product:last-child {
    margin-bottom: 0;
}

.wc-smart-upsell-product-image {
    flex-shrink: 0;
    width: 80px;
    height: 80px;
}

.wc-smart-upsell-product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 4px;
}

.wc-smart-upsell-no-image {
    width: 100%;
    height: 100%;
    background: #f0f0f0;
    border-radius: 4px;
}

.wc-smart-upsell-product-details {
    flex: 1;
    min-width: 0;
}

.wc-smart-upsell-product-name {
    margin: 0 0 6px;
    font-size: 15px;
    font-weight: 600;
}

.wc-smart-upsell-product-name a {
    color: #333;
    text-decoration: none;
}

.wc-smart-upsell-product-name a:hover {
    color: #0073aa;
}

.wc-smart-upsell-product-description {
    margin: 0 0 8px;
    font-size: 13px;
    color: #666;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.wc-smart-upsell-product-price {
    font-size: 14px;
}

.wc-smart-upsell-price-was {
    color: #999;
    margin-right: 8px;
}

.wc-smart-upsell-price-now {
    color: #e74c3c;
    font-weight: 600;
}

.wc-smart-upsell-savings {
    display: inline-block;
    background: #27ae60;
    color: #fff;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 3px;
    margin-left: 8px;
    font-weight: 600;
}

.wc-smart-upsell-product-actions {
    display: flex;
    align-items: center;
}

.wc-smart-upsell-add-btn {
    white-space: nowrap;
}

/* Modal Buttons */
.wc-smart-upsell-dismiss-btn {
    background: #f0f0f0 !important;
    color: #666 !important;
    border: 1px solid #ddd !important;
}

.wc-smart-upsell-dismiss-btn:hover {
    background: #e0e0e0 !important;
    color: #333 !important;
}

/* ==========================================================================
   Banner Styles
   ========================================================================== */

.wc-smart-upsell-banners {
    margin-bottom: 24px;
}

.wc-smart-upsell-banner {
    position: relative;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 8px;
    padding: 16px 20px;
    margin-bottom: 12px;
    color: #fff;
    box-shadow: 0 2px 10px rgba(102, 126, 234, 0.3);
}

.wc-smart-upsell-banner:last-child {
    margin-bottom: 0;
}

.wc-smart-upsell-banner-dismiss {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: #fff;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.wc-smart-upsell-banner-dismiss:hover {
    background: rgba(255, 255, 255, 0.3);
}

.wc-smart-upsell-banner-content {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.wc-smart-upsell-banner-image {
    flex-shrink: 0;
}

.wc-smart-upsell-banner-image img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 6px;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.wc-smart-upsell-banner-text {
    flex: 1;
    min-width: 200px;
}

.wc-smart-upsell-banner-title {
    display: block;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.wc-smart-upsell-banner-message {
    margin: 0;
    font-size: 15px;
    opacity: 0.95;
}

.wc-smart-upsell-banner-message a {
    color: #fff;
    text-decoration: underline;
}

.wc-smart-upsell-banner-message a:hover {
    text-decoration: none;
}

.wc-smart-upsell-banner-price {
    text-align: center;
    padding: 0 16px;
}

.wc-smart-upsell-banner-price .wc-smart-upsell-price-was {
    display: block;
    font-size: 12px;
    opacity: 0.8;
    color: #fff;
}

.wc-smart-upsell-banner-price .wc-smart-upsell-price-now,
.wc-smart-upsell-banner-price .wc-smart-upsell-price {
    display: block;
    font-size: 20px;
    font-weight: 700;
    color: #fff;
}

.wc-smart-upsell-banner-action {
    flex-shrink: 0;
}

.wc-smart-upsell-banner-add-btn {
    background: #fff !important;
    color: #667eea !important;
    border: none !important;
    font-weight: 600 !important;
    padding: 10px 20px !important;
    border-radius: 6px !important;
    transition: transform 0.2s ease, box-shadow 0.2s ease !important;
}

.wc-smart-upsell-banner-add-btn:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2) !important;
}

/* Upsell Badge in Cart */
.wc-smart-upsell-badge {
    display: inline-block;
    background: #27ae60;
    color: #fff;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 3px;
    margin-left: 6px;
    font-weight: 600;
    vertical-align: middle;
    text-transform: uppercase;
}

/* ==========================================================================
   Responsive Styles
   ========================================================================== */

@media (max-width: 600px) {
    /* Modal Mobile */
    .wc-smart-upsell-modal-content {
        width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }

    .wc-smart-upsell-modal-header {
        padding: 16px;
    }

    .wc-smart-upsell-modal-body {
        padding: 16px;
    }

    .wc-smart-upsell-modal-footer {
        padding: 12px 16px;
        flex-direction: column;
    }

    .wc-smart-upsell-modal-footer button {
        width: 100%;
        margin-bottom: 8px;
    }

    .wc-smart-upsell-modal-footer button:last-child {
        margin-bottom: 0;
    }

    .wc-smart-upsell-product {
        flex-direction: column;
        text-align: center;
    }

    .wc-smart-upsell-product-image {
        width: 100px;
        height: 100px;
        margin: 0 auto;
    }

    .wc-smart-upsell-product-actions {
        width: 100%;
        justify-content: center;
        margin-top: 12px;
    }

    .wc-smart-upsell-add-btn {
        width: 100%;
    }

    /* Banner Mobile */
    .wc-smart-upsell-banner {
        padding: 14px;
        padding-right: 36px;
    }

    .wc-smart-upsell-banner-content {
        flex-direction: column;
        text-align: center;
        gap: 12px;
    }

    .wc-smart-upsell-banner-text {
        min-width: 100%;
    }

    .wc-smart-upsell-banner-price {
        padding: 8px 0;
    }

    .wc-smart-upsell-banner-action {
        width: 100%;
    }

    .wc-smart-upsell-banner-add-btn {
        width: 100%;
    }
}

/* ==========================================================================
   Animation States
   ========================================================================== */

.wc-smart-upsell-banner.wc-smart-upsell-banner-dismissing {
    animation: wcSmartUpsellBannerOut 0.3s ease-out forwards;
}

@keyframes wcSmartUpsellBannerOut {
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

.wc-smart-upsell-product.wc-smart-upsell-product-added {
    background: #e8f5e9;
    border-color: #27ae60;
}

.wc-smart-upsell-add-btn.loading,
.wc-smart-upsell-banner-add-btn.loading {
    opacity: 0.7;
    pointer-events: none;
}

.wc-smart-upsell-add-btn.added,
.wc-smart-upsell-banner-add-btn.added {
    background: #27ae60 !important;
    color: #fff !important;
}

/* ==========================================================================
   Theme Override Fixes - High Specificity with ID selectors
   ========================================================================== */

/* Modal body - compact padding, no overflow issues */
#wc-smart-upsell-modal .wc-smart-upsell-modal-body {
    padding: 16px !important;
    overflow: visible !important;
    max-height: none !important;
}

/* Product Card - Compact horizontal layout */
#wc-smart-upsell-modal .wc-smart-upsell-product {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    gap: 12px !important;
    padding: 12px !important;
    margin: 0 0 12px 0 !important;
    border: 1px solid #e0e0e0 !important;
    border-radius: 8px !important;
    background: #fff !important;
    visibility: visible !important;
    opacity: 1 !important;
    min-height: auto !important;
    max-height: none !important;
    height: auto !important;
}

#wc-smart-upsell-modal .wc-smart-upsell-product:last-child {
    margin-bottom: 0 !important;
}

/* Product Image - Smaller for compact layout */
#wc-smart-upsell-modal .wc-smart-upsell-product-image {
    flex: 0 0 60px !important;
    width: 60px !important;
    height: 60px !important;
    min-width: 60px !important;
    min-height: 60px !important;
    max-width: 60px !important;
    max-height: 60px !important;
}

#wc-smart-upsell-modal .wc-smart-upsell-product-image img {
    width: 60px !important;
    height: 60px !important;
    object-fit: cover !important;
    border-radius: 4px !important;
}

/* Product Details - Flexible width */
#wc-smart-upsell-modal .wc-smart-upsell-product-details {
    flex: 1 1 auto !important;
    min-width: 100px !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Product Name */
#wc-smart-upsell-modal .wc-smart-upsell-product-name {
    display: block !important;
    visibility: visible !important;
    margin: 0 0 4px 0 !important;
    padding: 0 !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    line-height: 1.3 !important;
}

#wc-smart-upsell-modal .wc-smart-upsell-product-name a {
    color: #333 !important;
    text-decoration: none !important;
}

/* Product Price */
#wc-smart-upsell-modal .wc-smart-upsell-product-price {
    display: block !important;
    visibility: visible !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    color: #333 !important;
    margin: 0 !important;
    padding: 0 !important;
}

#wc-smart-upsell-modal .wc-smart-upsell-price,
#wc-smart-upsell-modal .wc-smart-upsell-price-now {
    color: #e74c3c !important;
    font-weight: 700 !important;
}

/* Product Actions - Add to Cart button */
#wc-smart-upsell-modal .wc-smart-upsell-product-actions {
    flex: 0 0 auto !important;
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    align-items: center !important;
}

#wc-smart-upsell-modal .wc-smart-upsell-add-btn {
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
    padding: 10px 18px !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    white-space: nowrap !important;
    background: #0073aa !important;
    color: #fff !important;
    border: none !important;
    border-radius: 4px !important;
    cursor: pointer !important;
    text-transform: none !important;
    line-height: 1.2 !important;
}

#wc-smart-upsell-modal .wc-smart-upsell-add-btn:hover {
    background: #005a87 !important;
}

/* Hide description in modal to save space */
#wc-smart-upsell-modal .wc-smart-upsell-product-description {
    display: none !important;
}

/* Hide savings badge in modal to save space */
#wc-smart-upsell-modal .wc-smart-upsell-savings {
    display: none !important;
}
