/* ==========================================================================
   عطور عساف | Assaf Perfumes - All-in-One Compact Order Pop-Up
   Single Viewport Box (No Page Scroll) + Multi-Product Cart + Live Search
   ========================================================================== */

/* --- 1. Backdrop Overlay --- */
.order-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(3, 4, 6, 0.88);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.3s;
    direction: rtl;
}

.order-modal-backdrop.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* --- 2. Single-Piece Compact Dialog Box --- */
.order-modal-dialog.compact-box {
    position: relative;
    width: 100%;
    max-width: 1040px;
    max-height: 90vh;
    background: linear-gradient(180deg, #0e1117 0%, #06070a 100%);
    border: 1.5px solid rgba(197, 160, 89, 0.45);
    border-radius: 26px;
    box-shadow: 0 30px 70px rgba(0, 0, 0, 0.95), 0 0 50px rgba(197, 160, 89, 0.16);
    padding: 24px 28px 22px;
    color: #ffffff;
    transform: scale(0.94) translateY(16px);
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s;
    opacity: 0;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* No outer modal scroll on desktop */
}

.order-modal-backdrop.active .order-modal-dialog.compact-box {
    transform: scale(1) translateY(0);
    opacity: 1;
}

/* --- 3. Modal Top Bar --- */
.modal-top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.modal-brand-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13.5px;
    font-weight: 700;
    color: #e5c483;
}

.badge-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 8px #22c55e;
}

.order-modal-close {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #cbd5e1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s ease;
}

.order-modal-close:hover {
    background: rgba(197, 160, 89, 0.25);
    border-color: #c5a059;
    color: #ffffff;
    transform: scale(1.08);
}

/* Mobile Steps Nav (Hidden on Desktop) */
.mobile-steps-nav {
    display: none;
}

/* --- 4. Main Two-Column Layout --- */
.modal-columns-container {
    display: grid;
    grid-template-columns: 1.15fr 0.95fr;
    gap: 22px;
    flex: 1;
    min-height: 0; /* Important for flex child with overflow */
    align-items: stretch;
}

.modal-col {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* --- 5. Panel 1: Product Catalog & Search --- */
.modal-col-products {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 20px;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 0;
}

.products-header {
    display: flex;
    align-items: center;
    gap: 10px;
}

.search-box-wrapper {
    position: relative;
    width: 100%;
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(197, 160, 89, 0.3);
    border-radius: 12px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-box-wrapper:focus-within {
    border-color: #e5c483;
    box-shadow: 0 0 12px rgba(197, 160, 89, 0.2);
    background: rgba(197, 160, 89, 0.05);
}

.search-icon {
    position: absolute;
    right: 12px;
    width: 17px;
    height: 17px;
    color: #c5a059;
    pointer-events: none;
}

.perfume-search-input {
    width: 100%;
    background: transparent;
    border: none;
    color: #ffffff;
    font-family: inherit;
    font-size: 13.5px;
    padding: 10px 38px 10px 36px;
    outline: none;
    box-sizing: border-box;
}

.perfume-search-input::placeholder {
    color: #64748b;
    font-size: 12.5px;
}

.search-clear-btn {
    position: absolute;
    left: 10px;
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    font-size: 13px;
    padding: 4px;
}

.search-clear-btn:hover {
    color: #ffffff;
}

/* Product Catalog List (Internal Scrollable) */
.products-catalog-scroll {
    flex: 1;
    min-height: 220px;
    max-height: 280px;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-left: 6px;
}

.products-catalog-scroll::-webkit-scrollbar {
    width: 5px;
}
.products-catalog-scroll::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 6px;
}
.products-catalog-scroll::-webkit-scrollbar-thumb {
    background: rgba(197, 160, 89, 0.4);
    border-radius: 6px;
}
.products-catalog-scroll::-webkit-scrollbar-thumb:hover {
    background: #c5a059;
}

/* Catalog Product Row */
.catalog-item-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 14px;
    padding: 8px 12px;
    transition: all 0.2s ease;
}

.catalog-item-row:hover {
    background: rgba(197, 160, 89, 0.07);
    border-color: rgba(197, 160, 89, 0.35);
}

.catalog-item-row.is-in-cart {
    background: linear-gradient(90deg, rgba(197, 160, 89, 0.15) 0%, rgba(20, 24, 32, 0.6) 100%);
    border-color: #e5c483;
}

.item-left-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1;
}

.item-thumb-wrap {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(197, 160, 89, 0.2) 0%, transparent 70%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.item-thumb-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.6));
}

.item-text-info {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.item-name {
    font-size: 13.5px;
    font-weight: 700;
    color: #f8fafc;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.catalog-item-row.is-in-cart .item-name {
    color: #faecc5;
}

.item-price {
    font-size: 12.5px;
    font-weight: 700;
    color: #e5c483;
    font-family: var(--font-numbers);
}

/* Add Button & Counter Stepper */
.item-actions {
    flex-shrink: 0;
}

.btn-add-item {
    background: rgba(197, 160, 89, 0.15);
    border: 1px solid rgba(197, 160, 89, 0.4);
    border-radius: 10px;
    color: #e5c483;
    font-size: 12.5px;
    font-weight: 700;
    padding: 6px 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 4px;
}

.btn-add-item:hover {
    background: #c5a059;
    color: #050608;
    transform: scale(1.04);
}

.item-stepper {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(197, 160, 89, 0.2);
    border: 1px solid #e5c483;
    border-radius: 10px;
    padding: 3px 6px;
}

.step-btn {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    background: #c5a059;
    color: #050608;
    border: none;
    font-size: 14px;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s ease;
}

.step-btn:hover {
    background: #faecc5;
}

.step-count {
    min-width: 20px;
    text-align: center;
    font-size: 13.5px;
    font-weight: 800;
    color: #ffffff;
    font-family: var(--font-numbers);
}

/* No search results state */
.catalog-empty-state {
    text-align: center;
    padding: 30px 10px;
    color: #94a3b8;
    font-size: 13px;
}

/* --- 6. Selected Cart Tray --- */
.selected-cart-tray {
    background: rgba(10, 12, 16, 0.7);
    border: 1px solid rgba(197, 160, 89, 0.25);
    border-radius: 14px;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tray-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12.5px;
}

.tray-title {
    color: #94a3b8;
    font-weight: 600;
}

.tray-subtotal {
    color: #e5c483;
    font-weight: 800;
    font-family: var(--font-numbers);
}

.tray-items-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    max-height: 64px;
    overflow-y: auto;
}

.tray-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(197, 160, 89, 0.15);
    border: 1px solid rgba(197, 160, 89, 0.35);
    border-radius: 8px;
    padding: 3px 8px;
    font-size: 11.5px;
    color: #f1f5f9;
}

.chip-qty {
    font-weight: 800;
    color: #e5c483;
    font-family: var(--font-numbers);
}

.chip-remove {
    background: none;
    border: none;
    color: #f87171;
    font-size: 12px;
    cursor: pointer;
    padding: 0 2px;
    line-height: 1;
}

.chip-remove:hover {
    color: #ffffff;
}

.tray-empty-hint {
    font-size: 12px;
    color: #64748b;
    font-style: italic;
}

.mobile-next-step-btn {
    display: none;
}

/* --- 7. Panel 2: Customer Checkout Form --- */
.modal-col-checkout {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.compact-checkout-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    height: 100%;
    justify-content: space-between;
}

.checkout-fields-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-row {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.compact-label {
    font-size: 12px;
    font-weight: 600;
    color: #cbd5e1;
    display: flex;
    align-items: center;
    gap: 4px;
}

.req {
    color: #f87171;
}

.jordan-tag {
    font-size: 10.5px;
    color: #e5c483;
    margin-right: auto;
}

.compact-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.04);
    border: 1.5px solid rgba(255, 255, 255, 0.12);
    border-radius: 11px;
    transition: all 0.2s ease;
}

.compact-input-wrap:focus-within {
    border-color: #c5a059;
    background: rgba(197, 160, 89, 0.06);
    box-shadow: 0 0 10px rgba(197, 160, 89, 0.2);
}

.compact-input-wrap.error {
    border-color: #ef4444 !important;
    background: rgba(239, 68, 68, 0.06) !important;
}

.compact-input-wrap.valid {
    border-color: #22c55e !important;
}

.compact-icon {
    position: absolute;
    right: 10px;
    width: 15px;
    height: 15px;
    color: #94a3b8;
    pointer-events: none;
}

.compact-input,
.compact-select {
    width: 100%;
    background: transparent;
    border: none;
    color: #ffffff;
    font-family: inherit;
    font-size: 13px;
    padding: 8px 32px 8px 10px;
    outline: none;
    box-sizing: border-box;
}

.compact-input::placeholder {
    color: #64748b;
    font-size: 12px;
}

.phone-wrap {
    direction: ltr;
}

.phone-code {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 0 8px;
    border-right: 1px solid rgba(255, 255, 255, 0.12);
    font-size: 12px;
    font-weight: 700;
    color: #e5c483;
    flex-shrink: 0;
    user-select: none;
    font-family: var(--font-numbers);
}

.phone-input {
    direction: ltr;
    text-align: left;
    padding: 8px 10px;
    font-family: var(--font-numbers);
}

.select-wrap {
    padding-right: 4px;
}

.compact-select {
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    padding-right: 12px;
}

.compact-select option {
    background: #0e1117;
    color: #ffffff;
}

.field-error-msg {
    font-size: 11px;
    color: #f87171;
    font-weight: 500;
    min-height: 14px;
    display: block;
}

/* --- 8. Bill Summary Box --- */
.compact-bill-box {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.02) 0%, rgba(197, 160, 89, 0.06) 100%);
    border: 1px solid rgba(197, 160, 89, 0.25);
    border-radius: 14px;
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.bill-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    color: #cbd5e1;
}

.free-text {
    color: #4ade80;
    font-weight: 700;
}

.cod-text {
    color: #e5c483;
    font-size: 11px;
    font-weight: 600;
}

.bill-divider {
    height: 1px;
    background: rgba(197, 160, 89, 0.2);
    margin: 2px 0;
}

.total-row {
    font-size: 14px;
}

.total-text {
    font-weight: 800;
    color: #f8fafc;
}

.total-amount {
    font-size: 18px;
    font-weight: 900;
    color: #e5c483;
    font-family: var(--font-numbers);
}

/* --- 9. Submit Button --- */
.compact-submit-btn {
    width: 100%;
    padding: 13px 20px;
    border-radius: 13px;
    background: linear-gradient(135deg, #e5c483 0%, #c5a059 50%, #957132 100%);
    color: #050608;
    border: none;
    font-size: 15px;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    cursor: pointer;
    box-shadow: 0 8px 22px rgba(197, 160, 89, 0.35);
    transition: all 0.25s ease;
    margin-top: 4px;
}

.compact-submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(197, 160, 89, 0.5);
    filter: brightness(1.05);
}

.compact-submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.submit-icon {
    width: 19px;
    height: 19px;
    flex-shrink: 0;
}

.mobile-back-btn {
    display: none;
}

/* --- 10. Success Screen --- */
.order-success-screen {
    text-align: center;
    padding: 30px 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    animation: fadeInModal 0.35s ease forwards;
}

@keyframes fadeInModal {
    from { opacity: 0; transform: scale(0.96); }
    to { opacity: 1; transform: scale(1); }
}

.success-checkmark-circle {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.2) 0%, rgba(34, 197, 94, 0.05) 100%);
    border: 2px solid #22c55e;
    color: #22c55e;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 25px rgba(34, 197, 94, 0.3);
}

.success-checkmark-circle svg {
    width: 32px;
    height: 32px;
}

.success-title {
    font-size: 22px;
    font-weight: 800;
    color: #f8fafc;
    margin: 0;
}

.success-desc {
    font-size: 13.5px;
    color: #94a3b8;
    max-width: 480px;
    line-height: 1.5;
    margin: 0;
}

.success-details-preview {
    width: 100%;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(197, 160, 89, 0.3);
    border-radius: 14px;
    padding: 14px;
    text-align: right;
    font-size: 12.5px;
    color: #cbd5e1;
    line-height: 1.6;
}

.manual-wa-link {
    display: inline-block;
    padding: 10px 20px;
    background: rgba(37, 211, 102, 0.15);
    border: 1px solid #25d366;
    border-radius: 12px;
    color: #4ade80;
    font-size: 13.5px;
    font-weight: 700;
    text-decoration: none;
    transition: all 0.2s ease;
}

.manual-wa-link:hover {
    background: #25d366;
    color: #050608;
}

/* --- 11. Responsive Mobile Styles --- */
@media (max-width: 820px) {
    .order-modal-dialog.compact-box {
        padding: 18px 16px 16px;
        max-height: 94vh;
        border-radius: 20px;
    }

    .modal-top-bar {
        margin-bottom: 10px;
        padding-bottom: 8px;
    }

    .modal-brand-badge {
        font-size: 12px;
    }

    /* Tabs navigation on mobile */
    .mobile-steps-nav {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        margin-bottom: 12px;
    }

    .step-nav-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
        padding: 8px;
        border-radius: 10px;
        background: rgba(255, 255, 255, 0.04);
        border: 1px solid rgba(255, 255, 255, 0.08);
        color: #94a3b8;
        font-size: 12px;
        font-weight: 700;
        cursor: pointer;
        transition: all 0.2s ease;
    }

    .step-nav-btn.active {
        background: rgba(197, 160, 89, 0.2);
        border-color: #e5c483;
        color: #faecc5;
    }

    .step-badge {
        width: 18px;
        height: 18px;
        border-radius: 50%;
        background: #c5a059;
        color: #050608;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 11px;
        font-weight: 800;
    }

    .modal-columns-container {
        grid-template-columns: 1fr;
        gap: 0;
    }

    /* On mobile, step toggling controls visibility */
    .modal-col-products {
        display: flex;
    }

    .modal-col-checkout {
        display: none;
    }

    .order-modal-dialog.show-step-2 .modal-col-products {
        display: none;
    }

    .order-modal-dialog.show-step-2 .modal-col-checkout {
        display: flex;
    }

    .products-catalog-scroll {
        max-height: 230px;
    }

    .mobile-next-step-btn {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        padding: 12px 16px;
        border-radius: 12px;
        background: linear-gradient(135deg, #e5c483 0%, #c5a059 100%);
        color: #050608;
        border: none;
        font-size: 14px;
        font-weight: 800;
        cursor: pointer;
        margin-top: 6px;
    }

    .btn-subtotal-badge {
        background: rgba(0, 0, 0, 0.2);
        padding: 3px 8px;
        border-radius: 6px;
        font-family: var(--font-numbers);
    }

    .mobile-back-btn {
        display: block;
        width: 100%;
        background: none;
        border: none;
        color: #94a3b8;
        font-size: 12px;
        padding: 8px;
        cursor: pointer;
        text-align: center;
    }

    .mobile-back-btn:hover {
        color: #e5c483;
    }
}
