/**
 * @package     Joomla.Plugin
 * @subpackage  J2Store.app_boxbuilderproduct
 *
 * @copyright Copyright (C) 2025 J2Commerce, LLC. All rights reserved.
 * @license https://www.gnu.org/licenses/gpl-3.0.html GNU/GPLv3 or later
 * @website https://www.j2commerce.com
 *
 * Box Builder Interactive - CSS Styles
 */

/* CSS Variables */
:root {
    --boxbuilder-primary: #2358ae;
    --boxbuilder-primary-hover: #133d81;
    --boxbuilder-selected-color: #288b53;
    --boxbuilder-selected-bg: #ebf7f0;
    --boxbuilder-selected-border: #d6f0e1;
    --boxbuilder-slot-border: #2358ae;
    --boxbuilder-slot-empty-bg: #eaf1fb;
    --boxbuilder-card-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --boxbuilder-card-shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.15);
    --boxbuilder-transition: 0.2s ease-in-out;
}

/* Container */
.boxbuilder-interactive-container {
    position: relative;
    padding-bottom: 80px;
}


.boxbuilder-interactive-container .fs-xs {
    font-size: 0.75rem!important;
}

@media (min-width: 992px) {
    .boxbuilder-interactive-container {
        padding-bottom: 0;
    }
}

/* Section Title */
.boxbuilder-section-title {
    font-weight: 600;
    color: #333;
}

/* Product Card */
.boxbuilder-products-grid {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr);
}

/* Responsive: 2 columns on medium screens */
@media (max-width: 991.98px) {
    .boxbuilder-products-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Responsive: 2 columns on small screens */
@media (max-width: 767.98px) {
    .boxbuilder-products-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Override Bootstrap col behavior within grid */
.boxbuilder-products-grid > .col {
    max-width: 100%;
    flex: none;
    width: auto;

}

/* Card fills grid cell with flex column layout */
.boxbuilder-products-grid .boxbuilder-product-card {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Image container expands to fill available space, stacks children vertically */
.boxbuilder-products-grid .boxbuilder-product-image {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* Card body anchored to bottom, doesn't grow */
.boxbuilder-products-grid .boxbuilder-product-card .card-body {
    flex: 0 0 auto;
    margin-top: auto;
}

.boxbuilder-product-card {
    transition: background-color var(--boxbuilder-transition);
    cursor: pointer;
    border: 2px solid transparent;
}

.boxbuilder-product-card:hover {
    /*box-shadow: var(--boxbuilder-card-shadow-hover);
    transform: translateY(-2px);*/
}

/* Selected State */
.boxbuilder-product-card.boxbuilder-product-selected {
    background-color: var(--boxbuilder-selected-bg);
    border-color: var(--boxbuilder-selected-border)!important;
}

/* Product Image */
.boxbuilder-product-image {
    position: relative;
    aspect-ratio: 1;
    overflow: hidden;
}

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

.boxbuilder-product-card:hover .boxbuilder-product-image img {

}



/* Out of Stock Badge */
.boxbuilder-out-of-stock-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background-color: #dc3545;
    color: white;
    padding: 4px 8px;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 4px;
    text-transform: uppercase;
}

/* Product Title */
.boxbuilder-product-title {
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1.3;
    min-height: 3rem;
    display: -webkit-box;
}

/* Add Button */
.boxbuilder-add-btn {
    font-weight: 600;
    transition: all var(--boxbuilder-transition);
}

.boxbuilder-add-container .boxbuilder-add-btn:disabled {
    --boxbuilder-selected-border: #2358ae;
    border-color: var(--boxbuilder-selected-border)!important;
}


.boxbuilder-add-icon {
    font-weight: bold;
    position:relative;
    top:-1px;
}

/* Quantity Selector */
.boxbuilder-quantity-selector {
    background-color: var(--boxbuilder-selected-bg);
    border-radius: 8px;
}

.boxbuilder-qty-value {
    font-weight: 600;
    font-size: 1rem;
    min-width: 24px;
    text-align: center;
    color: var(--boxbuilder-selected-color);
}

.boxbuilder-qty-minus,
.boxbuilder-qty-plus {
    width: 32px;
    height: 32px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    border-radius: 50%;
}

/* Sidebar */
.boxbuilder-sidebar {
    top: 100px;
}

.boxbuilder-sidebar .card {
    border: none;
    box-shadow: var(--boxbuilder-card-shadow);
    border-radius: 12px;
}

.boxbuilder-sidebar-title {
    font-weight: 700;
    color: #333;
}

/* Slots Grid */
.boxbuilder-slots-grid {
    display: grid;
    grid-template-columns: repeat(var(--boxbuilder-grid-cols, 4), 1fr);
    gap: 8px;
}

/* Slot */
.boxbuilder-slot {
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    transition: all var(--boxbuilder-transition);
}

.boxbuilder-slot-inner {
    width: 100%;
    height: 100%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Empty Slot */
.boxbuilder-slot-empty {
    border: 2px dashed var(--boxbuilder-slot-border);
    background-color: var(--boxbuilder-slot-empty-bg);
}

.boxbuilder-slot-placeholder {
    color: var(--boxbuilder-slot-border);
    opacity: 0.6;
}

/* Filled Slot */
.boxbuilder-slot-filled {
    --boxbuilder-selected-border: #2358ae;
    border: 2px solid var(--boxbuilder-selected-border);
    background-color: white;
}

.boxbuilder-slot-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Slot Remove Button */
.boxbuilder-slot-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    padding: 0;
    color: var(--boxbuilder-selected-color);
    background-color: transparent;
    border-radius: 50%;
    opacity: 0;
    transition: opacity var(--boxbuilder-transition);
}

.boxbuilder-slot-remove:hover {
    background-color:transparent;
}

.boxbuilder-slot-filled:hover .boxbuilder-slot-remove {
    opacity: 1;
}

/* Price Display */
.boxbuilder-sidebar-price {
    border-top: 1px solid #eee;
    border-bottom: 1px solid #eee;
    padding: 16px 0;
}

.boxbuilder-price-value {
    color: var(--boxbuilder-primary);
    font-weight: 700;
}

/* Progress Info */
.boxbuilder-progress-info {
    font-size: 0.9rem;
}

.boxbuilder-selected-count {
    font-weight: 600;
}

/* Action Button */
.boxbuilder-action-btn {
    font-weight: 600;
    padding: 12px 24px;
    transition: all var(--boxbuilder-transition);
}

.boxbuilder-action-btn:disabled {
    background-color: #6c757d;
    border-color: #6c757d;
    opacity: 0.7;
}


/* Full Message */
.boxbuilder-full-message {
    font-weight: 500;
}

/* Floating Bar (Mobile) */
.boxbuilder-floating-bar {
    position: fixed;
    bottom:0;
    left: 0;
    right: 0;
    background-color: white;
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.15);
    z-index: 1050;
    padding: 12px 16px;
}

.boxbuilder-floating-bar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    max-width: 100%;
}

.boxbuilder-progress-text {
    font-weight: 700;
    font-size: 0.9rem;
    white-space: nowrap;
}

.boxbuilder-progress-text .boxbuilder-count {

    color: var(--boxbuilder-primary);
}

.boxbuilder-floating-action {
    flex-shrink: 0;
    font-weight: 600;
    padding: 10px 20px;
}

/* Animations */
@keyframes boxbuilder-pop {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
    }
}

.boxbuilder-slot-animate {
    animation: boxbuilder-pop 0.3s ease-in-out;
}

@keyframes boxbuilder-shake {
    0%, 100% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-5px);
    }
    75% {
        transform: translateX(5px);
    }
}

.boxbuilder-shake {
    animation: boxbuilder-shake 0.3s ease-in-out;
}

/* Responsive adjustments */
@media (max-width: 575.98px) {
    .boxbuilder-product-title {
        font-size: 0.8rem;
    }

    .boxbuilder-slots-grid {
        gap: 6px;
    }

    .boxbuilder-floating-bar {
        padding: 10px 12px;
    }

    .boxbuilder-progress-text {
        font-size: 0.8rem;
    }

    .boxbuilder-floating-action {
        padding: 8px 16px;
        font-size: 0.85rem;
    }
}

@media (min-width: 768px) {
    .boxbuilder-actions-container {min-width:120px;}
    .boxbuilder-actions-container .boxbuilder-add-btn {width:108px;}
    .boxbuilder-add-icon {margin-right: 4px;}
}

@media (min-width: 992px) {
    .boxbuilder-sidebar {
        margin-top: 0;
    }
}

/* Print styles */
@media print {
    .boxbuilder-floating-bar {
        display: none !important;
    }

    .boxbuilder-add-btn,
    .boxbuilder-quantity-selector,
    .boxbuilder-action-btn,
    .boxbuilder-slot-remove {
        display: none !important;
    }
}
