/* ==========================================================================
   عطور عساف | Assaf Perfumes - All-in-One Compact Order Pop-Up
   Ultra-Responsive One-Section Layout (Desktop Dual-Column & Mobile Fullscreen)
   ========================================================================== */

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

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

/* --- 2. Single-Piece Compact Dialog Box (Desktop) --- */
.order-modal-dialog.compact-box {
    position: relative;
    width: 100%;
    max-width: 980px;
    height: 620px;
    max-height: calc(100vh - 40px);
    background: radial-gradient(110% 80% at 85% 10%, rgba(197, 160, 89, 0.09) 0%, transparent 60%),
                linear-gradient(180deg, #10131a 0%, #07080c 100%);
    border: 1.5px solid rgba(197, 160, 89, 0.4);
    border-radius: 24px;
    box-shadow: 0 35px 80px -10px rgba(0, 0, 0, 0.95),
                0 0 45px rgba(197, 160, 89, 0.14),
                inset 0 1px 0 rgba(255, 255, 255, 0.1);
    padding: 18px 22px 18px;
    color: #ffffff;
    transform: scale(0.96) translateY(12px);
    transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.28s;
    opacity: 0;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.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;
    gap: 12px;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}

.modal-brand-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1;
}

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

.brand-title {
    font-size: 13.5px;
    font-weight: 800;
    color: #faecc5;
    letter-spacing: 0.2px;
    white-space: nowrap;
}

.offer-pill {
    background: rgba(197, 160, 89, 0.12);
    border: 1px solid rgba(197, 160, 89, 0.35);
    color: #faecc5;
    font-size: 11.5px;
    padding: 3px 10px;
    border-radius: 20px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.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.14);
    color: #cbd5e1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 15px;
    font-weight: bold;
    transition: all 0.22s ease;
    flex-shrink: 0;
    padding: 0;
}

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

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

/* --- 4. Main Two-Column Layout --- */
.modal-columns-container {
    display: grid;
    grid-template-columns: 1.08fr 0.92fr;
    gap: 18px;
    flex: 1;
    min-height: 0;
    align-items: stretch;
}

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

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

.products-header {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.search-box-wrapper {
    position: relative;
    width: 100%;
    height: 38px;
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(197, 160, 89, 0.32);
    border-radius: 10px;
    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.25);
    background: rgba(197, 160, 89, 0.05);
}

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

.perfume-search-input {
    width: 100%;
    height: 100%;
    background: transparent;
    border: none;
    color: #ffffff;
    font-family: inherit;
    font-size: 12.5px;
    padding: 0 34px 0 32px;
    outline: none;
    box-sizing: border-box;
}

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

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

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

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

.products-catalog-scroll::-webkit-scrollbar,
.checkout-scrollable-body::-webkit-scrollbar,
.tray-items-list::-webkit-scrollbar {
    width: 4px;
}

.products-catalog-scroll::-webkit-scrollbar-track,
.checkout-scrollable-body::-webkit-scrollbar-track,
.tray-items-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.02);
    border-radius: 4px;
}

.products-catalog-scroll::-webkit-scrollbar-thumb,
.checkout-scrollable-body::-webkit-scrollbar-thumb,
.tray-items-list::-webkit-scrollbar-thumb {
    background: rgba(197, 160, 89, 0.4);
    border-radius: 4px;
}

.products-catalog-scroll::-webkit-scrollbar-thumb:hover,
.checkout-scrollable-body::-webkit-scrollbar-thumb:hover {
    background: #c5a059;
}

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

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

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

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

.item-thumb-wrap {
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(197, 160, 89, 0.22) 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 2px 5px rgba(0, 0, 0, 0.6));
}

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

.item-name {
    font-size: 12.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: 11.5px;
    font-weight: 800;
    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: 8px;
    color: #e5c483;
    font-size: 11.5px;
    font-weight: 700;
    padding: 5px 12px;
    cursor: pointer;
    transition: all 0.18s ease;
    display: flex;
    align-items: center;
    gap: 4px;
}

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

.item-stepper {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(197, 160, 89, 0.22);
    border: 1px solid #e5c483;
    border-radius: 8px;
    padding: 2px 4px;
}

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

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

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

.catalog-empty-state {
    text-align: center;
    padding: 24px 10px;
    color: #94a3b8;
    font-size: 12.5px;
}

/* Products Action Footer (Cart Tray + Mobile Next Button) */
.products-action-footer {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-shrink: 0;
    margin-top: auto;
}

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

.tray-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 11.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: 5px;
    max-height: 52px;
    overflow-y: auto;
}

.tray-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: rgba(197, 160, 89, 0.14);
    border: 1px solid rgba(197, 160, 89, 0.35);
    border-radius: 7px;
    padding: 2px 7px;
    font-size: 11px;
    color: #f1f5f9;
}

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

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

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

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

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

/* --- 7. Column 2: Customer Checkout Form --- */
.modal-col-checkout {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 18px;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.compact-checkout-form {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}

/* Internal Scrollable Section for form fields & bill on tiny devices */
.checkout-scrollable-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-left: 2px;
}

.checkout-fields-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-shrink: 0;
}

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

.form-row-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

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

.req {
    color: #f87171;
}

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

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

.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: 9px;
    width: 14px;
    height: 14px;
    color: #94a3b8;
    pointer-events: none;
}

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

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

.phone-wrap {
    direction: ltr;
}

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

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

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

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

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

/* Field errors: zero height when empty so no space is wasted */
.field-error-msg {
    font-size: 10.5px;
    color: #f87171;
    font-weight: 600;
    display: none;
    margin-top: 1px;
}

.field-error-msg:not(:empty) {
    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.22);
    border-radius: 12px;
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex-shrink: 0;
}

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

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

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

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

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

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

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

/* Checkout Action Footer (Submit & Back) */
.checkout-action-footer {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex-shrink: 0;
    margin-top: auto;
    padding-top: 6px;
}

/* --- 9. Submit Button --- */
.compact-submit-btn {
    width: 100%;
    height: 46px;
    border-radius: 12px;
    background: linear-gradient(135deg, #faecc5 0%, #c5a059 50%, #957132 100%);
    color: #050608;
    border: none;
    font-size: 14.5px;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    box-shadow: 0 6px 22px rgba(197, 160, 89, 0.35);
    transition: all 0.22s ease;
    flex-shrink: 0;
    padding: 0 16px;
}

.compact-submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 26px rgba(197, 160, 89, 0.48);
    filter: brightness(1.04);
}

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

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

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

/* --- 10. Success Screen --- */
.order-success-screen {
    text-align: center;
    padding: 24px 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    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: 58px;
    height: 58px;
    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 22px rgba(34, 197, 94, 0.3);
}

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

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

.success-desc {
    font-size: 12.5px;
    color: #94a3b8;
    max-width: 440px;
    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: 12px;
    padding: 12px;
    text-align: right;
    font-size: 12px;
    color: #cbd5e1;
    line-height: 1.6;
}

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

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

/* ==========================================================================
   --- 11. Responsive Mobile Styles (The 1-Section Full-Screen Mobile App) ---
   ========================================================================== */
@media (max-width: 820px) {
    /* Backdrop occupies exact full screen with 0 margin */
    .order-modal-backdrop {
        padding: 0;
        align-items: stretch;
        justify-content: stretch;
    }

    /* Dialog takes 100% width and 100dvh (One complete section) */
    .order-modal-dialog.compact-box {
        width: 100vw;
        width: 100%;
        height: 100%;
        height: 100dvh;
        max-height: 100dvh;
        border-radius: 0;
        border: none;
        box-shadow: none;
        padding: max(10px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom)) 12px;
        transform: translateY(10px);
    }

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

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

    .brand-title {
        font-size: 12.5px;
    }

    .offer-pill {
        display: none; /* Keep top bar clean and single-line on mobile */
    }

    .order-modal-close {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }

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

    .step-nav-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
        height: 34px;
        padding: 0 8px;
        border-radius: 9px;
        background: rgba(255, 255, 255, 0.04);
        border: 1px solid rgba(255, 255, 255, 0.08);
        color: #94a3b8;
        font-size: 11.5px;
        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;
        box-shadow: 0 2px 10px rgba(197, 160, 89, 0.2);
    }

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

    .modal-columns-container {
        display: flex;
        flex-direction: column;
        flex: 1;
        min-height: 0;
        gap: 0;
    }

    /* Step 1: Products Panel on Mobile */
    .modal-col-products {
        display: flex;
        flex-direction: column;
        flex: 1;
        min-height: 0;
        background: transparent;
        border: none;
        padding: 0;
        gap: 6px;
    }

    /* Step 2: Checkout Panel on Mobile */
    .modal-col-checkout {
        display: none;
        flex-direction: column;
        flex: 1;
        min-height: 0;
        background: transparent;
        border: none;
        padding: 0;
    }

    /* Step toggling */
    .order-modal-dialog.show-step-2 .modal-col-products {
        display: none !important;
    }

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

    .products-catalog-scroll {
        flex: 1;
        min-height: 0;
        padding-left: 2px;
    }

    .mobile-next-step-btn {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        height: 44px;
        padding: 0 14px;
        border-radius: 11px;
        background: linear-gradient(135deg, #faecc5 0%, #c5a059 60%, #957132 100%);
        color: #050608;
        border: none;
        font-size: 13.5px;
        font-weight: 800;
        cursor: pointer;
        flex-shrink: 0;
        box-shadow: 0 6px 18px rgba(197, 160, 89, 0.35);
    }

    .btn-subtotal-badge {
        background: rgba(0, 0, 0, 0.2);
        padding: 2px 7px;
        border-radius: 5px;
        font-family: var(--font-numbers);
        font-size: 12px;
    }

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

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

    /* Sticky Footer Buttons inside form */
    .checkout-action-footer {
        flex-shrink: 0;
        margin-top: auto;
        padding-top: 6px;
    }

    .compact-submit-btn {
        height: 44px;
        font-size: 14px;
    }
}
