/* Mobile Drawer Menu Styles */

/* Design Tokens */
:root {
    /* Brand Colors */
    --brand-blue-primary: #191E67;
    --brand-blue-secondary: #4564ED;
    --brand-blue-container: #F0F3FE;

    /* Background Colors */
    --background-white: #FFFFFF;
    --background-primary: #F3F3F3;

    /* Text Colors */
    --text-primary: #3D3D3D;
    --text-secondary: #888888;

    /* Border Colors */
    --border-default: #E7E7E7;

    /* Font Weights */
    --font-regular: 400;
    --font-medium: 510;
    --font-semibold: 590;
    --font-bold: 700;

    /* Spacing */
    --space-0: 0px;
    --space-4: 4px;
    --space-8: 8px;
    --space-12: 12px;
    --space-16: 16px;
    --space-20: 20px;

    /* Border Radius */
    --radius-sm: 4.763px;
    --radius-md: 8px;
    --radius-lg: 12px;
}

/* Overlay */
.mobile-drawer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.mobile-drawer-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Drawer Container - Full Screen */
.mobile-drawer {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100vh;
    /* background: var(--background-primary); */
    background: var(--Background-Primary, #F3F3F3);
    z-index: 10000;
    transform: translateX(-100%);
    transition: transform 0.3s ease-in-out;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.mobile-drawer[data-drawer-state="open"],
.mobile-drawer.active {
    transform: translateX(0);
}

/* Header positioning when drawer is open - Only on mobile */
@media (max-width: 991px) {
    body:has(.mobile-drawer.active) header,
    body:has(.mobile-drawer[data-drawer-state="open"]) header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 10001;
        width: 100%;
    }

    body:has(.mobile-drawer.active) .header-menu,
    body:has(.mobile-drawer[data-drawer-state="open"]) .header-menu {
        position: relative;
        z-index: 10001;
        background: #FFFFFF;
        box-shadow: 0px 4px 4px -8px rgba(0, 0, 0, 0.08),
                    0px 4px 16px 10px rgba(16, 24, 40, 0.02),
                    0px 2px 32px -4px rgba(16, 24, 40, 0.03);
    }

    body:has(.mobile-drawer.active) .header-menu .search-box,
    body:has(.mobile-drawer[data-drawer-state="open"]) .header-menu .search-box {
        background: var(--brand-blue-container);
        border: 1px solid var(--border-default);
    }

    body:has(.mobile-drawer.active) .header-menu .search-input::placeholder,
    body:has(.mobile-drawer[data-drawer-state="open"]) .header-menu .search-input::placeholder {
        color: var(--text-secondary);
    }
}

/* Hide mobile location bar when drawer is open */
body:has(.mobile-drawer.active) .mobile-location-bar,
body:has(.mobile-drawer[data-drawer-state="open"]) .mobile-location-bar {
    display: none;
}

/* Hide overlay when using full screen drawer */
body:has(.mobile-drawer.active) .mobile-drawer-overlay,
body:has(.mobile-drawer[data-drawer-state="open"]) .mobile-drawer-overlay {
    display: none;
}

/* Drawer Content */
.mobile-drawer-content {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: calc(100vh - 56px); /* Full height minus header */
    margin-top: 56px; /* Height of mobile header menu */
    overflow-y: auto; /* Enable scroll for login + menu */
    overflow-x: hidden;
}

/* Login Banner */
.mobile-drawer .login-banner {
    width: 100%;
    min-height: auto;
    background: var(--background-white);
    border-top: 0.586px solid var(--border-default);
    overflow: hidden;
    /* padding: var(--space-16); */
    padding: 19px 16px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    order: 1; /* Login banner on top */
    position: relative;
}

.login-banner .banner-content {
    display: flex;
    flex-direction: column;
    /* gap: var(--space-12); */
    gap: 3px;
    flex: 1;
    max-width: 204px;
}

.login-banner .banner-title {
    font-family: 'SF Pro', sans-serif;
    font-weight: var(--font-bold);
    font-size: 14px;
    line-height: 18.751px;
    letter-spacing: -0.14px;
    color: var(--text-primary);
    margin: 0;
    width: 220px;
}

.login-banner .banner-subtitle {
    font-family: 'SF Pro', sans-serif;
    font-weight: var(--font-regular);
    font-size: 10px;
    line-height: 14.063px;
    letter-spacing: -0.1px;
    color: var(--text-secondary);
    margin: 9px 0 0 0;
    width: 235px;
}

.login-banner .btn-login {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 9.376px;
    gap: var(--space-8);
    border: 0.879px solid var(--brand-blue-secondary);
    border-radius: var(--radius-sm);
    background: transparent;
    font-family: 'SF Pro', sans-serif;
    font-weight: var(--font-medium);
    font-size: 10px;
    line-height: 11.72px;
    color: var(--brand-blue-secondary);
    cursor: pointer;
    width: fit-content;
    white-space: pre;
    transition: all 0.2s ease;
}

.login-banner .btn-login:hover {
    background: var(--brand-blue-secondary);
    color: var(--background-white);
}

.login-banner .banner-illustration {
    width: 154px;
    height: auto;
    max-height: 86px;
    object-fit: contain;
    flex-shrink: 0;
    position: absolute;
    bottom: 0; right: 16px;
}

/* Login Banner - Logged In State */
.login-banner.logged-in {
    padding: var(--space-16);
    background: #F7F7F7;
    border-top: 0.586px solid var(--border-default);
    display: block;
    flex-shrink: 0;
    order: 1; /* Login banner on top */
}

.user-info-mobile {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: var(--space-16);
    background: var(--background-white);
    border-radius: 12px;
    box-shadow: 0px 4px 4px -8px rgba(0, 0, 0, 0.08),
                0px 4px 16px 10px rgba(16, 24, 40, 0.02),
                0px 2px 32px -4px rgba(16, 24, 40, 0.03);
}

.user-header-mobile {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.user-name-mobile {
    font-family: 'SF Pro', sans-serif;
    font-weight: 700;
    font-size: 16px;
    line-height: 21px;
    letter-spacing: -0.16px;
    color: #1A1A1A;
    margin: 0;
    flex: 1;
}

.fgold-badge-mobile {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    background: #8B93AD;
    border-radius: 100px;
    flex-shrink: 0;
}

.fgold-icon-mobile {
    width: 14px;
    height: 14px;
    object-fit: contain;
}

.fgold-amount-mobile {
    font-family: 'SF Pro', sans-serif;
    font-weight: 600;
    font-size: 11px;
    line-height: 15px;
    color: var(--background-white);
    white-space: nowrap;
}

.user-address-mobile {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.contract-id-mobile {
    font-family: 'SF Pro', sans-serif;
    font-weight: 600;
    font-size: 13px;
    line-height: 17px;
    color: #1A1A1A;
}

.address-text-mobile {
    font-family: 'SF Pro', sans-serif;
    font-weight: 400;
    font-size: 11px;
    line-height: 15px;
    letter-spacing: -0.11px;
    color: #6B6B6B;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-actions-mobile {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}

.btn-user-action-mobile {
    width: 100%;
    padding: 12px 16px;
    border-radius: 8px;
    font-family: 'SF Pro', sans-serif;
    font-weight: 600;
    font-size: 13px;
    line-height: 17px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

.btn-primary-mobile {
    background: #4564ED;
    color: var(--background-white);
}

.btn-primary-mobile:hover {
    background: #3851D9;
}

.btn-secondary-mobile {
    background: var(--background-white);
    color: #4564ED;
    border: 1px solid #E0E0E0;
}

.btn-secondary-mobile:hover {
    background: #F5F7FF;
    border-color: #4564ED;
}

/* Navigation */
.drawer-nav {
    display: flex;
    flex-direction: column;
    padding: var(--space-16);
    padding-bottom: 0; /* Remove bottom padding to account for logout button */
    width: 100%;
    flex: 0 1 auto; /* Don't force height, let content determine */
    order: 2; /* Nav in middle */
    overflow: visible; /* Remove individual scroll */
    /* background: #F7F7F8;  */
    /* Layer 1: Gray background for entire nav */
}

.drawer-nav .nav-container {
    display: flex;
    flex-direction: column;
    gap: var(--space-12);
    padding: 0;
}

/* Menu Item */
.menu-item {
    background: #FFFFFF; /* Layer 2: White card for each menu item */
    border-radius: var(--radius-lg);
    width: 100%;
    box-shadow: 0px 1px 3px rgba(0, 0, 0, 0.05);
    transition: background-color 0.15s ease;
}

.menu-item.expandable {
    border-radius: var(--radius-lg);
}

.menu-item:not(.expandable) .menu-item-header {
    padding: var(--space-12);
}

.menu-item.menu-item-2 .category-links,
.menu-item.menu-item-3 .category-links,
.menu-item.menu-item-5 .category-links,
.menu-item.menu-item-tt .category-links, 
.menu-item.menu-item-ud .category-links,
.menu-item.menu-item-k .category-links {
    padding: 0;
}

.menu-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: var(--space-12) var(--space-12) 0 var(--space-12);
    gap: 10px;
    border: none;
    background: transparent;
    cursor: pointer;
    text-align: left;
    text-decoration: none;
    color: inherit;
    transition: background 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

.menu-item-header:active,
.menu-item-header:focus {
    outline: none;
    background: transparent;
}

.menu-item:active {
    background: rgba(247, 247, 248, 1);
}


.menu-title {
    font-family: 'SF Pro', sans-serif;
    font-weight: var(--font-semibold);
    font-size: 16px;
    line-height: 24px;
    color: var(--text-primary);
    white-space: pre;
}

/* Chevron Icon */
.chevron {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    transform: rotate(180deg) scaleY(-1);
    transition: transform 0.3s ease;
}

.menu-item-header[aria-expanded="true"] .chevron,
.drawer-nav-toggle.active .chevron {
    transform: rotate(0deg) scaleY(1);
}

/* Submenu Dropdown */
.menu-dropdown,
.drawer-submenu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease,  padding 0.4s ease;;
    padding: 0 var(--space-12) 0;
    background: #F7F7F8; /* Layer 3: Gray background inside white card */
    border-radius: var(--space-8);
    /* border-radius: 0 0 var(--radius-lg) var(--radius-lg); */
     /* Rounded bottom to match parent */
    margin: 0 var(--space-12) var(--space-12);
    transition: all 0.3s ease;
}


.menu-dropdown[hidden] {
    display: block;
}

.menu-dropdown:not([hidden]),
.drawer-submenu.active {
    /* max-height: 3000px; */
    margin-top: var(--space-12);
    transition: all 0.3s ease;
}

.drawer-submenu-inner {
    padding-top: var(--space-12); /* Add top padding for spacing */
    padding-bottom: var(--space-12);
}

/* Submenu Category */
.drawer-submenu-category {
    background: transparent; /* No background, use parent gray */
    border-radius: 0;
    padding: var(--space-0) 0;
    /* margin-bottom: 32px; */
    margin-bottom: 40px;
}

.drawer-submenu-category:last-child {
    margin-bottom: 0;
}

.drawer-submenu-category.no-icon .category-links {
    margin-top: 0;
}

/* Category Header */
.category-header {
    display: flex;
    align-items: center;
    gap: 24px;
    margin-bottom: 20px;
    cursor: pointer;
    padding: 4px;
    margin: -4px -4px 0px -4px;
    border-radius: 4px;
    transition: background 0.2s ease;
}

.category-header:hover {
    background: rgba(0, 0, 0, 0.03);
}

.category-icon {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    pointer-events: none;
}

.category-title {
    font-family: 'SF Pro', sans-serif;
    font-weight: var(--font-semibold);
    font-size: 16px;
    line-height: 1.4;
    color: var(--text-primary);
    pointer-events: none;
}

/* Category Links */
.category-links {
    display: flex;
    flex-direction: column;
    gap: var(--space-12);
}

.drawer-submenu-link {
    display: flex;
    align-items: center;
    gap: var(--space-8);
    font-family: 'SF Pro', sans-serif;
    font-size: 16px;
    font-weight: var(--font-regular);
    line-height: 1.4;
    color: var(--text-primary);
    text-decoration: none;
    transition: color 0.2s ease, font-weight 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    background: transparent;
}

.drawer-submenu-category.no-icon .drawer-submenu-link {
    padding-left: 16px;
}

.drawer-submenu-link:hover,
.drawer-submenu-link:active,
.drawer-submenu-link:focus {
    background: transparent;
    outline: none;
}

.drawer-submenu-link:active {
    font-weight: var(--font-bold);
    color: #FF730A;
}

.drawer-submenu-link.highlight {
    font-weight: var(--font-bold);
    color: #FF730A;
}

/* Badge */
.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    border-radius: 999px;
    font-family: 'SF Pro', sans-serif;
    font-weight: var(--font-medium);
    font-size: 12px;
    line-height: 0;
    white-space: nowrap;
}

.badge-new {
    background: #FF2156;
    color: #FFFFFF;
}

/* Logout Button */
.drawer-logout {
    padding: var(--space-12) var(--space-16);
    padding-bottom: calc(var(--space-12) + env(safe-area-inset-bottom));
    background: var(--background-white);
    box-shadow: 0px -2px 8px rgba(0, 0, 0, 0.05);
    flex-shrink: 0;
    order: 3; /* Logout button at bottom */
    position: sticky; /* Keep it fixed at bottom during scroll */
    bottom: 0;
    z-index: 10;
    margin-top: auto; /* Push to bottom */
}

.btn-logout {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    padding: 12px 16px;
    background: transparent;
    border: none;
    border-radius: 8px;
    font-family: 'SF Pro', sans-serif;
    font-weight: 600;
    font-size: 14px;
    line-height: 18px;
    color: #3D3D3D;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-logout svg {
    flex-shrink: 0;
}

.btn-logout:hover {
    background: #F7F7F7;
}

.btn-logout:active {
    background: #EEEEEE;
}

/* Hide on Desktop */
@media (min-width: 992px) {
    .mobile-drawer,
    .mobile-drawer-overlay {
        display: none;
    }
}
