.jd-my-account-wrapper {
    position: relative;
    display: inline-block;
    cursor: pointer;
}

.jd-my-account-trigger {
    display: inline-flex;
    align-items: center;
    color: inherit;
    text-decoration: none;
    transition: all 0.3s ease;
    line-height: 1;
}

.jd-my-account-trigger i {
    transition: color 0.3s ease;
}

.jd-my-account-trigger svg {
    transition: fill 0.3s ease;
}

/* Dropdown Base */
.jd-my-account-dropdown {
    position: absolute;
    top: 100%;
    background: #ffffff;
    min-width: 220px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    border-radius: 8px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
    z-index: 9999;
}

/* Position Variants */
.jd-my-account-dropdown.pos-left { 
    left: 0; 
}
.jd-my-account-dropdown.pos-right { 
    right: 0; 
}
.jd-my-account-dropdown.pos-center { 
    left: 50%; 
    transform: translateX(-50%) translateY(10px); 
}

/* Hover Physics */
.jd-my-account-wrapper:hover .jd-my-account-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
.jd-my-account-wrapper:hover .jd-my-account-dropdown.pos-center {
    transform: translateX(-50%) translateY(0);
}

/* Dropdown Content Specs */
.jd-my-account-header {
    padding: 15px 20px;
    border-bottom: 1px solid #f0f0f0;
    font-weight: 600;
    font-size: 14px;
    color: #1a1a1a;
}

.jd-my-account-list {
    list-style: none !important;
    margin: 0 !important;
    padding: 10px 0 !important;
}

.jd-my-account-list li {
    margin: 0 !important;
    padding: 0 !important;
}

.jd-my-account-list li::before {
    display: none !important;
}

.jd-my-account-list a {
    display: block;
    padding: 10px 20px;
    color: #4a4a4a;
    text-decoration: none;
    font-size: 14px;
    transition: background 0.2s ease, color 0.2s ease, padding-left 0.2s ease;
}

.jd-my-account-list a:hover {
    background: #f8f9fa;
    color: #000;
    padding-left: 23px; /* Premium interaction */
}

/* ── Unauthenticated State (Login/Register) ── */
.jd-logout-desc {
    font-size: 13px;
    color: #666;
    margin: 0 0 15px 0 !important;
    line-height: 1.4;
}

.unauthenticated-body {
    padding: 24px;
    text-align: center;
}

.jd-my-acc-btn-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.jd-my-acc-btn {
    display: block !important;
    width: 100% !important;
    box-sizing: border-box !important;
    padding: 12px 20px;
    border-radius: 8px;
    text-decoration: none !important;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.2s ease !important;
    border: 2px solid transparent;
    text-align: center !important;
    line-height: 1.2;
    cursor: pointer;
}

.jd-my-acc-btn.btn-primary {
    background-color: #0f172a;
    color: #fff;
    border-color: #0f172a;
}

.jd-my-acc-btn.btn-primary:hover {
    background-color: #1e293b;
    border-color: #1e293b;
}

.jd-my-acc-btn.btn-outline {
    background-color: transparent;
    color: #0f172a;
    border-color: #0f172a;
}

.jd-my-acc-btn.btn-outline:hover {
    background-color: #0f172a;
    color: #fff;
}

/* Specifically hide mobile close button on desktop */
.jd-my-account-wrapper .hide-on-desktop,
.jd-mobile-close { display: none !important; }

.jd-my-account-overlay { display: none; }


/* ── Mobile Off-Canvas / Dropdown Physics (Screens < 768px) ── */
@media (max-width: 767px) {
    /* 1. Prevent accidental hover triggers strictly */
    .jd-my-account-wrapper:hover .jd-my-account-dropdown {
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transform: translateY(10px);
    }
    .jd-my-account-wrapper:hover .jd-my-account-dropdown.pos-center {
        transform: translateX(-50%) translateY(10px);
    }

    /* 2. Style the dropdown as a fluid native box relative to header */
    .jd-my-account-wrapper[data-interaction="hover"] .jd-my-account-dropdown {
        position: absolute;
        top: calc(100% + 15px);
        bottom: auto;
        /* Center it relative to the right-aligned icon, but force it to stay on screen */
        right: 0 !important;
        left: auto !important;
        width: 320px !important;
        max-width: calc(100vw - 30px);
        transform: translateY(10px) !important;
        border-radius: 12px;
        z-index: 999999;
        transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s ease;
        opacity: 0; 
        visibility: hidden;
        pointer-events: none;
        box-shadow: 0 10px 40px rgba(0,0,0,0.18);
    }

    /* 3. Javascript Active State */
    .jd-my-account-wrapper[data-interaction="hover"].mob-active .jd-my-account-dropdown {
        opacity: 1;
        visibility: visible;
        transform: translateY(0) !important;
        pointer-events: auto;
    }

    /* Active Mobile Overlay (Soft darken background to focus user) */
    .jd-my-account-overlay {
        display: block;
        position: fixed;
        /* Escapes flow to cover screen softly, even if inside transformed sticky header 
           the 100vh will still visually cover thanks to massive span */
        top: -100vh;
        left: -100vw;
        width: 300vw;
        height: 300vh;
        background: rgba(0,0,0,0.4);
        z-index: 999998;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease;
        pointer-events: none;
    }

    .jd-my-account-wrapper[data-interaction="hover"].mob-active .jd-my-account-overlay {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    /* Header adjustments for Close Button */
    .jd-my-account-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 16px 20px;
    }

    .jd-my-account-wrapper .hide-on-desktop,
    .jd-mobile-close {
        display: block !important;
    }
    
    .jd-mobile-close {
        background: none !important;
        border: none !important;
        font-size: 24px !important;
        line-height: 1 !important;
        color: #999 !important;
        cursor: pointer !important;
        padding: 0 !important;
        transition: color 0.2s !important;
        box-shadow: none !important;
        margin: 0 !important;
    }

    .jd-mobile-close:hover {
        color: #000 !important;
    }
}
