/* assets/css/addon-modal.css */
/* Product Addon Modal Styling - Mobile Responsive */

/* ========= MODAL OVERLAY ========= */
.addon-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.addon-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ========= MODAL CONTAINER ========= */
.addon-modal-container {
    background: var(--ud-surface, #ffffff);
    border-radius: var(--ud-radius-lg, 16px);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
    position: relative;
    transform: scale(0.9) translateY(20px);
    transition: transform 0.3s ease;
    overflow: hidden;
}

.addon-modal-overlay.active .addon-modal-container {
    transform: scale(1) translateY(0);
}

/* ========= CLOSE BUTTON ========= */
.addon-modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--ud-surface, #ffffff);
    border: 1px solid var(--ud-border-subtle, #e5e7eb);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    transition: all 0.2s ease;
    color: var(--ud-text-main, #202124);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.addon-modal-close:hover {
    background: var(--ud-surface-soft, #fff3fd);
    border-color: var(--ud-primary, #B81B84);
    color: var(--ud-primary, #B81B84);
    transform: scale(1.05);
}

.addon-modal-close:active {
    transform: scale(0.95);
}

/* ========= PRODUCT HEADER ========= */
.addon-product-header {
    padding: 20px;
    border-bottom: 1px solid var(--ud-border-subtle, #e5e7eb);
    display: flex;
    gap: 16px;
    align-items: flex-start;
    flex-shrink: 0;
    padding-right: 60px; /* Space for close button */
}

.addon-product-image {
    width: 80px;
    height: 80px;
    border-radius: var(--ud-radius-md, 10px);
    overflow: hidden;
    flex-shrink: 0;
    background: var(--ud-surface-soft, #fff3fd);
    display: flex;
    align-items: center;
    justify-content: center;
}

.addon-product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.addon-product-info {
    flex: 1;
    min-width: 0;
}

.addon-product-name {
    font-size: 18px;
    font-weight: 600;
    color: var(--ud-text-strong, #111827);
    margin: 0 0 6px 0;
    line-height: 1.3;
    word-wrap: break-word;
}

.addon-product-desc {
    font-size: 14px;
    color: var(--ud-text-muted, #6b7280);
    margin: 0 0 10px 0;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.addon-product-base-price {
    display: flex;
    align-items: baseline;
    gap: 2px;
    font-size: 18px;
    font-weight: 700;
    color: var(--ud-primary, #B81B84);
}

.addon-currency {
    font-family: var(--ud-font-currency, "Noto Sans Bengali", system-ui, sans-serif);
    font-size: 0.85em;
    font-weight: 600;
}

/* ========= SCROLLABLE CONTENT AREA ========= */
.addon-groups-container {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    min-height: 150px;
    max-height: 50vh;
    -webkit-overflow-scrolling: touch;
}

.addon-groups-container::-webkit-scrollbar {
    width: 5px;
}

.addon-groups-container::-webkit-scrollbar-track {
    background: transparent;
}

.addon-groups-container::-webkit-scrollbar-thumb {
    background: var(--ud-border-subtle, #e5e7eb);
    border-radius: 3px;
}

.addon-groups-container::-webkit-scrollbar-thumb:hover {
    background: var(--ud-text-muted, #6b7280);
}

/* ========= ADDON GROUP ========= */
.addon-group {
    margin-bottom: 24px;
}

.addon-group:last-child {
    margin-bottom: 0;
}

.addon-group-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
    gap: 12px;
}

.addon-group-title-wrapper {
    flex: 1;
}

.addon-group-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--ud-text-strong, #111827);
    margin: 0 0 4px 0;
}

.addon-group-subtitle {
    font-size: 12px;
    color: var(--ud-text-muted, #6b7280);
    margin: 0;
}

.addon-required-badge {
    background: var(--ud-primary-soft, #FFC5E8);
    color: var(--ud-primary, #B81B84);
    font-size: 10px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: var(--ud-radius-full, 9999px);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}

/* ========= ADDON ITEMS LIST ========= */
.addon-items-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.addon-item {
    position: relative;
}

.addon-item-input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.addon-item-label {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border: 2px solid var(--ud-border-subtle, #e5e7eb);
    border-radius: var(--ud-radius-md, 10px);
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--ud-surface, #ffffff);
    min-height: 52px;
}

.addon-item-label:hover {
    border-color: var(--ud-primary, #B81B84);
    background: var(--ud-surface-soft, #fff3fd);
}

.addon-item-input:checked + .addon-item-label {
    border-color: var(--ud-primary, #B81B84);
    background: var(--ud-surface-soft, #fff3fd);
}

/* ========= CUSTOM CHECKMARK/RADIO ========= */
.addon-item-checkmark {
    width: 22px;
    height: 22px;
    border: 2px solid var(--ud-border-subtle, #e5e7eb);
    border-radius: 6px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    position: relative;
}

.addon-item-input[type="radio"] + .addon-item-label .addon-item-checkmark {
    border-radius: 50%;
}

.addon-item-input:checked + .addon-item-label .addon-item-checkmark {
    background: var(--ud-primary, #B81B84);
    border-color: var(--ud-primary, #B81B84);
}

.addon-item-input:checked + .addon-item-label .addon-item-checkmark::after {
    content: '';
    display: block;
    width: 6px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    margin-top: -2px;
}

.addon-item-input[type="radio"]:checked + .addon-item-label .addon-item-checkmark::after {
    width: 8px;
    height: 8px;
    background: white;
    border: none;
    border-radius: 50%;
    transform: none;
    margin-top: 0;
}

/* ========= ADDON ITEM CONTENT ========= */
.addon-item-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.addon-item-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--ud-text-strong, #111827);
    line-height: 1.3;
}

.addon-item-desc {
    font-size: 12px;
    color: var(--ud-text-muted, #6b7280);
    line-height: 1.4;
}

.addon-item-price {
    font-size: 14px;
    font-weight: 600;
    color: var(--ud-text-main, #202124);
    flex-shrink: 0;
    display: flex;
    align-items: baseline;
    gap: 2px;
    white-space: nowrap;
}

.addon-item-price .addon-currency {
    font-size: 0.8em;
}

/* ========= LOADING STATE ========= */
.addon-loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 50px 24px;
    gap: 16px;
}

.addon-loading-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--ud-border-subtle, #e5e7eb);
    border-top-color: var(--ud-primary, #B81B84);
    border-radius: 50%;
    animation: addon-spin 0.8s linear infinite;
}

@keyframes addon-spin {
    to {
        transform: rotate(360deg);
    }
}

.addon-loading-state p {
    font-size: 14px;
    color: var(--ud-text-muted, #6b7280);
    margin: 0;
}

/* ========= EMPTY STATE ========= */
.addon-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 50px 24px;
    gap: 12px;
    text-align: center;
}

.addon-empty-state svg {
    color: var(--ud-text-muted, #6b7280);
}

.addon-empty-state p {
    font-size: 14px;
    color: var(--ud-text-muted, #6b7280);
    margin: 0;
}

/* ========= MODAL FOOTER ========= */
.addon-modal-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--ud-border-subtle, #e5e7eb);
    display: flex;
    align-items: center;
    gap: 16px;
    flex-shrink: 0;
    background: var(--ud-surface, #ffffff);
}

/* ========= QUANTITY SELECTOR ========= */
.addon-quantity-selector {
    display: flex;
    align-items: center;
    gap: 4px;
    border: 2px solid var(--ud-border-subtle, #e5e7eb);
    border-radius: var(--ud-radius-md, 10px);
    padding: 4px;
    background: var(--ud-surface, #ffffff);
}

.addon-qty-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    color: var(--ud-primary, #B81B84);
    font-size: 20px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.addon-qty-btn:hover {
    background: var(--ud-surface-soft, #fff3fd);
}

.addon-qty-btn:active {
    transform: scale(0.9);
}

.addon-qty-value {
    min-width: 32px;
    text-align: center;
    font-size: 16px;
    font-weight: 600;
    color: var(--ud-text-strong, #111827);
}

/* ========= ADD TO CART BUTTON ========= */
.addon-add-to-cart {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px;
    background: var(--ud-primary, #B81B84);
    color: white;
    border: none;
    border-radius: var(--ud-radius-md, 10px);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(184, 27, 132, 0.25);
    min-height: 52px;
    -webkit-tap-highlight-color: transparent;
}

.addon-add-to-cart:hover {
    background: var(--ud-primary-dark, #4A0032);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(184, 27, 132, 0.35);
}

.addon-add-to-cart:active {
    transform: translateY(0);
}

.addon-cart-total {
    display: flex;
    align-items: baseline;
    gap: 2px;
    font-size: 16px;
}

.addon-cart-total .addon-currency {
    font-size: 0.85em;
}

/* ========= TABLET RESPONSIVE (768px) ========= */
@media (max-width: 768px) {
    .addon-modal-overlay {
        padding: 16px;
    }

    .addon-modal-container {
        max-width: 100%;
        max-height: 85vh;
    }

    .addon-product-header {
        padding: 16px;
        padding-right: 52px;
    }

    .addon-product-image {
        width: 70px;
        height: 70px;
    }

    .addon-product-name {
        font-size: 16px;
    }

    .addon-groups-container {
        padding: 14px 16px;
        max-height: 45vh;
    }

    .addon-modal-footer {
        padding: 14px 16px;
    }
}

/* ========= MOBILE RESPONSIVE (640px) ========= */
@media (max-width: 640px) {
    .addon-modal-overlay {
        padding: 0;
        align-items: flex-end;
    }

    .addon-modal-container {
        max-width: 100%;
        max-height: 92vh;
        border-radius: var(--ud-radius-xl, 24px) var(--ud-radius-xl, 24px) 0 0;
        animation: slideUp 0.3s ease;
    }

    @keyframes slideUp {
        from {
            transform: translateY(100%);
        }
        to {
            transform: translateY(0);
        }
    }

    .addon-modal-overlay.active .addon-modal-container {
        transform: translateY(0);
    }

    /* Drag handle for mobile */
    .addon-modal-container::before {
        content: '';
        position: absolute;
        top: 8px;
        left: 50%;
        transform: translateX(-50%);
        width: 40px;
        height: 4px;
        background: var(--ud-border-subtle, #e5e7eb);
        border-radius: var(--ud-radius-full, 9999px);
        z-index: 11;
    }

    .addon-modal-close {
        top: 16px;
        right: 12px;
        width: 36px;
        height: 36px;
    }

    .addon-product-header {
        padding: 24px 16px 16px;
        padding-right: 50px;
        flex-direction: row;
        gap: 12px;
    }

    .addon-product-image {
        width: 64px;
        height: 64px;
    }

    .addon-product-name {
        font-size: 15px;
    }

    .addon-product-desc {
        font-size: 13px;
        -webkit-line-clamp: 1;
    }

    .addon-product-base-price {
        font-size: 16px;
    }

    .addon-groups-container {
        padding: 12px 16px;
        max-height: 40vh;
    }

    .addon-group {
        margin-bottom: 20px;
    }

    .addon-group-title {
        font-size: 14px;
    }

    .addon-item-label {
        padding: 10px 12px;
        gap: 10px;
        min-height: 48px;
    }

    .addon-item-checkmark {
        width: 20px;
        height: 20px;
    }

    .addon-item-name {
        font-size: 13px;
    }

    .addon-item-price {
        font-size: 13px;
    }

    .addon-modal-footer {
        padding: 12px 16px;
        padding-bottom: max(12px, env(safe-area-inset-bottom));
        flex-direction: column;
        gap: 12px;
    }

    .addon-quantity-selector {
        width: fit-content;
        align-self: center;
    }

    .addon-qty-btn {
        width: 40px;
        height: 40px;
    }

    .addon-add-to-cart {
        width: 100%;
        justify-content: center;
        min-height: 50px;
    }
}

/* ========= SMALL MOBILE (400px) ========= */
@media (max-width: 400px) {
    .addon-product-header {
        flex-direction: column;
        text-align: center;
        padding-right: 16px;
    }

    .addon-product-image {
        width: 100%;
        height: 140px;
        margin: 0 auto;
    }

    .addon-product-info {
        width: 100%;
    }

    .addon-product-base-price {
        justify-content: center;
    }

    .addon-item-label {
        padding: 10px;
    }

    .addon-item-content {
        font-size: 13px;
    }

    .addon-modal-footer {
        gap: 10px;
    }
}

/* ========= LANDSCAPE MOBILE ========= */
@media (max-height: 500px) and (orientation: landscape) {
    .addon-modal-overlay {
        padding: 8px;
        align-items: center;
    }

    .addon-modal-container {
        max-height: 95vh;
        border-radius: var(--ud-radius-md, 10px);
        flex-direction: row;
        max-width: 100%;
    }

    .addon-modal-container::before {
        display: none;
    }

    .addon-product-header {
        width: 200px;
        flex-direction: column;
        border-bottom: none;
        border-right: 1px solid var(--ud-border-subtle);
        padding: 12px;
        padding-right: 12px;
        flex-shrink: 0;
    }

    .addon-product-image {
        width: 100%;
        height: 80px;
    }

    .addon-groups-container {
        flex: 1;
        max-height: none;
        padding: 12px;
    }

    .addon-modal-footer {
        position: absolute;
        bottom: 0;
        left: 200px;
        right: 0;
        border-top: 1px solid var(--ud-border-subtle);
        flex-direction: row;
    }
}

/* ========= ANIMATIONS ========= */
@keyframes addon-fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.addon-modal-overlay.active .addon-groups-container > * {
    animation: addon-fadeIn 0.3s ease forwards;
}

/* ========= ACCESSIBILITY ========= */
@media (prefers-reduced-motion: reduce) {
    .addon-modal-overlay,
    .addon-modal-container,
    .addon-item-label,
    .addon-qty-btn,
    .addon-add-to-cart {
        transition: none;
    }

    .addon-loading-spinner {
        animation: none;
    }

    .addon-modal-overlay.active .addon-groups-container > * {
        animation: none;
    }
}

/* Focus visible for keyboard navigation */
.addon-modal-close:focus-visible,
.addon-qty-btn:focus-visible,
.addon-add-to-cart:focus-visible,
.addon-item-label:focus-visible {
    outline: 2px solid var(--ud-primary, #B81B84);
    outline-offset: 2px;
}

.addon-item-input:focus-visible + .addon-item-label {
    outline: 2px solid var(--ud-primary, #B81B84);
    outline-offset: 2px;
}
