/**
 * SM Bundle Plugin - Frontend Styles
 * ABC-style bundle display with savings badges
 */

/* ==========================================================================
   Variables
   ========================================================================== */
:root {
    --sm-bundle-primary: #ff7837;
    --sm-bundle-primary-light: #ff7837;
    --sm-bundle-primary-dark: rgb(216, 103, 47);
    --sm-bundle-success: rgb(216, 103, 47);
    --sm-bundle-savings: #e53935;
    --sm-bundle-promo: #ff7837;
    --sm-bundle-gray-50: #fafafa;
    --sm-bundle-gray-100: #f5f5f5;
    --sm-bundle-gray-200: #eeeeee;
    --sm-bundle-gray-300: #e0e0e0;
    --sm-bundle-gray-400: #bdbdbd;
    --sm-bundle-gray-500: #9e9e9e;
    --sm-bundle-gray-600: #757575;
    --sm-bundle-gray-700: #616161;
    --sm-bundle-gray-800: #424242;
    --sm-bundle-gray-900: #212121;
    --sm-bundle-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --sm-bundle-shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
    --sm-bundle-radius: 10px;
    --sm-bundle-radius-sm: 10px;
}

/* ==========================================================================
   Bundle Options Container
   ========================================================================== */
.sm-bundle-options {
    margin: 24px 0;
    font-family:
        -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu,
        sans-serif;
}

.sm-bundle-options.sm-abc-style {
    margin: 20px 0;
}

.sm-bundle-options-header {
    margin-bottom: 16px;
}

.sm-bundle-options-header h4 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--sm-bundle-gray-800);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ==========================================================================
   ABC-Style Product Grid
   ========================================================================== */
.sm-bundle-list.abc-products-grid {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* ==========================================================================
   ABC-Style Product Item
   ========================================================================== */
.abc-product-item.sm-bundle-item {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    padding: 0;
    border: 1px solid #ddd;
    background: #fff;
    border-radius: var(--sm-bundle-radius);
    overflow: hidden;
    position: relative;
}

/* ==========================================================================
   Promo Text Topbar
   ========================================================================== */
.sm-bundle-promo-topbar {
    width: 100%;
    background: linear-gradient(
        135deg,
        var(--sm-bundle-promo) 0%,
        #ff9a5a 100%
    );
    color: #ffffff;
    padding: 10px 15px;
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    line-height: 1.4;
}

/* ==========================================================================
   Product Image
   ========================================================================== */
.abc-product-item.sm-bundle-item .abc-product-image {
    margin: 15px;
    margin-right: 0;
    flex-shrink: 0;
}

.abc-product-item.sm-bundle-item .abc-product-image img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: var(--sm-bundle-radius-sm);
    border: 1px solid var(--sm-bundle-gray-200);
}

/* ==========================================================================
   Product Info
   ========================================================================== */
.abc-product-item.sm-bundle-item .abc-product-info {
    flex: 1;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 200px;
}

.abc-product-item.sm-bundle-item .abc-product-title {
    margin: 0;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
}

.abc-product-item.sm-bundle-item .abc-product-title a {
    color: var(--sm-bundle-gray-800);
    text-decoration: none;
}

.abc-product-item.sm-bundle-item .abc-product-title a:hover {
    color: var(--sm-bundle-primary);
}

/* ==========================================================================
   Action Row - Button + Badge
   ========================================================================== */
.sm-bundle-action-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
}

/* Button styling */
.sm-bundle-action-row .add_to_cart_button {
    flex-shrink: 0;
    margin: 0;
    padding: 10px 16px;
    background: var(--sm-bundle-primary);
    color: #fff !important;
    border-radius: var(--sm-bundle-radius-sm);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    border: none;
    cursor: pointer;
    white-space: nowrap;
}

.sm-bundle-action-row .add_to_cart_button:hover {
    background: var(--sm-bundle-primary-dark);
    transform: translateY(-1px);
}

/* Savings Badge - Right side styling */
.sm-bundle-action-row .sm-bundle-savings-badge {
    display: inline-block;
    color: #fff;
    padding: 6px 12px;
    border-radius: var(--sm-bundle-radius-sm);
    font-size: 16px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    flex-shrink: 0;
    color: red;
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */
@media screen and (max-width: 768px) {
    .sm-bundle-options-header h4 {
        font-size: 16px;
    }

    .abc-product-item.sm-bundle-item .abc-product-image {
        margin: 12px;
        margin-right: 0;
    }

    .abc-product-item.sm-bundle-item .abc-product-image img {
        width: 70px;
        height: 70px;
    }

    .abc-product-item.sm-bundle-item .abc-product-info {
        padding: 12px;
        gap: 8px;
    }

    .abc-product-item.sm-bundle-item .abc-product-title {
        font-size: 13px;
    }

    .sm-bundle-action-row {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .sm-bundle-action-row .add_to_cart_button {
        padding: 8px 14px;
        font-size: 12px;
        width: 100%;
        text-align: center;
    }

    .sm-bundle-action-row .sm-bundle-savings-badge {
        padding: 5px 10px;
        font-size: 11px;
        width: 100%;
        text-align: center;
    }

    .sm-bundle-promo-topbar {
        padding: 8px 12px;
        font-size: 12px;
    }
}

@media screen and (max-width: 480px) {
    .abc-product-item.sm-bundle-item {
        flex-direction: column;
        text-align: center;
    }

    .abc-product-item.sm-bundle-item .abc-product-image {
        margin: 15px auto 0;
    }

    .abc-product-item.sm-bundle-item .abc-product-image img {
        width: 80px;
        height: 80px;
    }

    .abc-product-item.sm-bundle-item .abc-product-info {
        align-items: center;
        min-width: auto;
        width: 100%;
    }

    .sm-bundle-action-row {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .sm-bundle-action-row .add_to_cart_button {
        width: 100%;
        max-width: 250px;
    }

    .sm-bundle-action-row .sm-bundle-savings-badge {
        width: 100%;
        max-width: 250px;
        text-align: center;
    }
}

/* ==========================================================================
   Button Loading & Added States
   ========================================================================== */
.abc-product-item.sm-bundle-item .add_to_cart_button.loading {
    opacity: 0.7;
    pointer-events: none;
    position: relative;
}

.abc-product-item.sm-bundle-item .add_to_cart_button.loading::after {
    content: '';
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    border: 2px solid #fff;
    border-top-color: transparent;
    border-radius: 50%;
    animation: sm-bundle-spin 0.8s linear infinite;
}

@keyframes sm-bundle-spin {
    to {
        transform: translateY(-50%) rotate(360deg);
    }
}

.abc-product-item.sm-bundle-item .add_to_cart_button.added {
    background: var(--sm-bundle-success);
}

/* ==========================================================================
   Product Group Modal
   ========================================================================== */
.sm-bundle-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sm-bundle-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.sm-bundle-modal-container {
    position: relative;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    background: #fff;
    border-radius: var(--sm-bundle-radius);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: sm-modal-slide-in 0.3s ease;
    z-index:999999999;
}

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

.sm-bundle-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--sm-bundle-gray-200);
    background: var(--sm-bundle-gray-50);
}

.sm-bundle-modal-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--sm-bundle-gray-900);
}

.sm-bundle-modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: var(--sm-bundle-gray-500);
    border-radius: 50%;
    transition: all 0.2s ease;
    padding: 0;
}

.sm-bundle-modal-close:hover {
    background: var(--sm-bundle-gray-200);
    color: var(--sm-bundle-gray-800);
}

.sm-bundle-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.sm-bundle-modal-products {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sm-bundle-modal-product {
    display: flex;
    align-items: center;
    padding: 12px;
    background: #fff;
    border: 2px solid var(--sm-bundle-gray-200);
    border-radius: var(--sm-bundle-radius);
    cursor: pointer;
    transition: all 0.2s ease;
}

.sm-bundle-modal-product:hover {
    border-color: var(--sm-bundle-primary);
    background: var(--sm-bundle-gray-50);
}

.sm-bundle-modal-product.selected {
    border-color: var(--sm-bundle-primary);
    background: rgba(152, 66, 66, 0.08);
}

.sm-bundle-modal-product-image {
    width: 60px;
    height: 60px;
    flex-shrink: 0;
    margin-right: 12px;
}

.sm-bundle-modal-product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--sm-bundle-gray-200);
}

.sm-bundle-modal-product-info {
    flex: 1;
    min-width: 0;
}

.sm-bundle-modal-product-name {
    margin: 0 0 4px 0;
    font-size: 14px;
    font-weight: 500;
    color: var(--sm-bundle-gray-800);
    line-height: 1.3;
}

.sm-bundle-modal-product-prices {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sm-bundle-modal-product-price {
    font-size: 15px;
    font-weight: 700;
    color: var(--sm-bundle-primary);
}

.sm-bundle-modal-product-original-price {
    font-size: 13px;
    font-weight: 500;
    color: var(--sm-bundle-gray-500);
    position: relative;
    display: inline-block;
    text-decoration: none;
}

.sm-bundle-modal-product-original-price::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    height: 0.9px;
    background-color: currentColor;
    transform: rotate(-15deg);
}

.sm-bundle-modal-product-check {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    margin-left: 12px;
    border: 2px solid var(--sm-bundle-gray-300);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sm-bundle-modal-product.selected .sm-bundle-modal-product-check {
    background: var(--sm-bundle-primary);
    border-color: var(--sm-bundle-primary);
}

.sm-bundle-modal-product-check .checkmark {
    display: none;
    width: 10px;
    height: 6px;
    border-left: 2px solid #fff;
    border-bottom: 2px solid #fff;
    transform: rotate(-45deg);
    margin-bottom: 2px;
}

.sm-bundle-modal-product.selected .sm-bundle-modal-product-check .checkmark {
    display: block;
}

.sm-bundle-modal-footer {
    display: flex;
    padding: 16px 20px;
    border-top: 1px solid var(--sm-bundle-gray-200);
    background: var(--sm-bundle-gray-50);
}

.sm-bundle-modal-footer .button {
    flex: 1;
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 600;
    border-radius: var(--sm-bundle-radius-sm);
    cursor: pointer;
    text-align: center;
    border: none;
    background: var(--sm-bundle-primary) !important;
}

.sm-bundle-modal-add-to-cart {
    background: var(--sm-bundle-primary) !important;
    color: #fff !important;
}

.sm-bundle-modal-add-to-cart:hover:not(:disabled) {
    background: var(--sm-bundle-primary-dark);
}

.sm-bundle-modal-add-to-cart:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.sm-bundle-modal-add-to-cart.loading {
    position: relative;
    color: transparent !important;
}

.sm-bundle-modal-add-to-cart.loading::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 18px;
    height: 18px;
    border: 2px solid #fff;
    border-top-color: transparent;
    border-radius: 50%;
    animation: sm-bundle-spin 0.8s linear infinite;
}

/* Body scroll lock when modal is open */
body.sm-bundle-modal-open {
    overflow: hidden;
}

/* ==========================================================================
   Modal Responsive Design
   ========================================================================== */
@media screen and (max-width: 768px) {
    .sm-bundle-modal-container {
        width: 95%;
        max-height: 85vh;
    }

    .sm-bundle-modal-header {
        padding: 14px 16px;
    }

    .sm-bundle-modal-title {
        font-size: 16px;
    }

    .sm-bundle-modal-body {
        padding: 12px;
    }

    .sm-bundle-modal-product {
        padding: 10px;
    }

    .sm-bundle-modal-product-image {
        width: 50px;
        height: 50px;
        margin-right: 10px;
    }

    .sm-bundle-modal-product-name {
        font-size: 13px;
    }

    .sm-bundle-modal-product-price {
        font-size: 14px;
    }

    .sm-bundle-modal-product-original-price {
        font-size: 12px;
    }

    .sm-bundle-modal-footer {
        padding: 14px 16px;
    }

    .sm-bundle-modal-footer .button {
        padding: 14px 20px;
    }
}

@media screen and (max-width: 480px) {
    .sm-bundle-modal-container {
        width: 100%;
        max-width: 100%;
        max-height: 100%;
        height: 100%;
        border-radius: 0;
    }

    .sm-bundle-modal-header {
        padding: 16px;
    }

    .sm-bundle-modal-body {
        padding: 16px;
    }

    .sm-bundle-modal-product {
        padding: 12px;
    }

    .sm-bundle-modal-product-image {
        width: 56px;
        height: 56px;
    }

    .sm-bundle-modal-footer {
        padding: 16px;
    }

    .sm-bundle-modal-footer .button {
        padding: 16px 20px;
        font-size: 15px;
    }
}
