/**
 * Addon Products CSS Styles
 *
 * Include this CSS file in your theme's stylesheet or enqueue it properly.
 */

/* Addon Products Container */
.addon-products-container {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #eee;
    width: 100%;
}

/* Addon Products Header */
.addon-products-header {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin: 0 0 12px 0;
    text-align: center;
}

/* Addon Products Preview Grid */
.addon-products-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 12px;
}

.addon-product-item {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 4px;
    border: 1px solid #f0f0f0;
    border-radius: 6px;
    transition: all 0.3s ease;
    cursor: pointer;
}

/* Desktop: Hide product info in preview grid, show only thumbnails */
.addon-product-item .addon-product-info {
    display: none;
}

.addon-product-image {
    width: 70px;
    height: 72px;
    overflow: hidden;
    margin: 0 auto;
}

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

/* View All Addons Button */
.view-all-addons-btn {
    margin-top: 12px;
    padding: 10px 16px;
    background: #0cb15d;
    color: white;
    border: 1px solid #0cb15d;
    border-radius: 5px;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    transition: all 0.2s ease;
    font-size: 14px;
}

/* Addon Modal */
.addon-modal {
    display: none;
    position: fixed;
    z-index: 99990000;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100vh;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.addon-modal.active {
    display: block;
    opacity: 1;
}

.addon-modal-content {
    background-color: #fff;
    margin: 3% auto;
    border-radius: 10px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
    width: 95%;
    max-width: 600px;
    max-height: 80vh;
    position: relative;
    transform: translateY(-20px);
    opacity: 0;
    transition: none;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.addon-modal.active .addon-modal-content {
    transform: translateY(0);
    opacity: 1;
}

/* Ensure modal covers everything including headers */
.addon-modal.active {
    z-index: 999999 !important;
}

.addon-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 1px solid #e0e0e0;
    flex-shrink: 0;
    position: relative;
}

.addon-modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.close-addon-modal {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 24px;
    font-weight: bold;
    color: #999;
    cursor: pointer;
    transition: color 0.2s ease;
    background: none;
    border: none;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.addon-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
}

.addon-products-grid-modal {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
}

.addon-product-modal-item {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 12px;
    transition: all 0.3s;
    position: relative;
    cursor: default;
    background: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

/* Modal items: Show product info */
.addon-product-modal-item .addon-product-info {
    display: block !important;
    width: 100%;
}

.addon-product-modal-item .addon-product-image {
    width: 80px;
    height: 80px;
    margin-bottom: 8px;
}

.addon-product-modal-item .addon-product-title {
    font-size: 14px;
    font-weight: 500;
    margin: 0 0 6px 0;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.addon-product-modal-item .addon-product-info hr {
    margin: 6px 0;
    border: none;
    border-top: 1px solid #eee;
}

.addon-product-modal-item .addon-add-to-cart-btn {
    width: 100%;
    padding: 8px 12px;
    margin-top: 6px;
    font-size: 12px;
}

.addon-add-to-cart-btn {
    width: 100%;
    padding: 8px 12px;
    margin-top: 8px;
    background: #0cb15d;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: normal;
    word-wrap: break-word;
    line-height: 1.2;
}

/* Make price text white in buttons */
.addon-add-to-cart-btn .woocommerce-Price-amount,
.addon-add-to-cart-btn .woocommerce-Price-currencySymbol,
.addon-add-to-cart-btn del,
.addon-add-to-cart-btn ins,
.addon-add-to-cart-btn .amount,
.addon-add-to-cart-btn bdi {
    color: white !important;
}

/* Hide crossed-through original price in buttons */
.addon-add-to-cart-btn del {
    display: none !important;
}

.addon-add-to-cart-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

.addon-product-title {
    font-size: 12px;
    font-weight: 500;
    color: #333;
    margin: 0 0 4px 0;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.addon-product-title a {
    color: inherit;
    text-decoration: none;
    transition: color 0.2s ease;
}

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

.addon-product-info hr {
    border: none;
    border-top: 1px solid #eee;
    margin: 6px 0;
}

.error-message,
.no-addon-products {
    text-align: center;
    padding: 30px 20px;
    color: #666;
}

/* Animations */
@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* Mobile: Show addon products as list instead of modal */
@media (max-width: 768px) {
    /* Hide modal on mobile */
    .addon-modal {
        display: none !important;
    }

    /* Show addon products directly on mobile */
    .addon-products-container {
        display: block !important;
        margin-top: 20px;
        padding-top: 20px;
        border-top: 1px solid #eee;
    }

    /* Mobile list layout - show all items */
    .addon-products-grid {
        display: block !important;
        margin-bottom: 0;
    }

    /* Mobile item styling - vertical list */
    .addon-product-item {
        display: block !important;
        border: 1px solid #f0f0f0;
        border-radius: 8px;
        padding: 12px;
        margin-bottom: 12px;
        background: white;
        width: 100%;
        box-sizing: border-box;
    }

    /* Mobile header styling */
    .addon-products-header {
        font-size: 18px;
        margin: 0 0 15px 0;
        text-align: left;
    }

    /* Mobile: Show product info in list layout */
    .addon-product-info {
        display: block !important;
        overflow: hidden;
        padding-left: 0;
    }

    /* Mobile item content layout */
    .addon-product-image {
        width: 60px;
        height: 60px;
        margin: 0;
        float: left;
        margin-right: 12px;
        border-radius: 6px;
    }

    .addon-product-title {
        font-size: 14px;
        font-weight: 500;
        margin: 0 0 4px 0;
        line-height: 1.4;
    }

    .addon-product-info hr {
        display: none;
    }

    .addon-add-to-cart-btn {
        width: 100%;
        padding: 10px 16px;
        margin-top: 8px;
        background: #0cb15d;
        color: white;
        border: none;
        border-radius: 6px;
        font-size: 13px;
        font-weight: 500;
        cursor: pointer;
        transition: all 0.2s ease;
        white-space: normal;
        word-wrap: break-word;
        line-height: 1.2;
    }

    .addon-add-to-cart-btn:disabled {
        background: #ccc;
        cursor: not-allowed;
        transform: none;
    }

    /* Hide the view all button on mobile since we show all items */
    .view-all-addons-btn {
        display: none;
    }
}
