/* ============================================
   BHD Woo Wallet - Mobile Layout (Sticky Header + Tabs)
   Optimized for 60fps performance
   ============================================ */

/* ============================================
   PERFORMANCE OPTIMIZATIONS
   ============================================ */

/* Enable hardware acceleration for smooth animations */
.bhd-mobile-header,
.bhd-tab,
.bhd-tab-indicator {
    will-change: transform;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

/* Smooth scrolling with momentum */
.bhd-tabs-scroll {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

/* ============================================
   HIDE MOBILE HEADER ON DESKTOP BY DEFAULT
   ============================================ */

/* Hide mobile header on desktop (>1024px) */
.bhd-mobile-header {
    display: none !important;
}

/* ============================================
   MOBILE LAYOUT - ONLY ACTIVE ON <1024px
   ============================================ */

@media (max-width: 1024px) {

    /* Hide desktop sidebar */
    .woocommerce-MyAccount-navigation {
        display: none !important;
    }

    .bhd-profile-card {
        display: none !important;
    }

    .bhd-sidebar-wrapper {
        display: none !important;
    }

    /* Full width content */
    .woocommerce-account .woocommerce {
        display: block !important;
    }

    .woocommerce-MyAccount-content {
        width: 100% !important;
        float: none !important;
    }

    /* ============================================
       STICKY HEADER
       ============================================ */

    .bhd-mobile-header {
        display: block !important;
        /* Show on mobile */
        position: sticky;
        top: 0;
        z-index: 100;
        background: var(--bhd-bg-secondary, #FFFFFF);
        box-shadow: 0 2px 8px var(--bhd-shadow-sm, rgba(0, 0, 0, 0.05));
        padding: 12px 0 8px 0;
        /* Remove horizontal padding */
        margin: -20px 0 20px 0;
        /* Remove negative horizontal margin */
        transition: box-shadow 0.2s ease;
        overflow: visible !important;
        /* Allow avatar glow and frame to show */
    }

    /* Enhanced shadow when scrolled */
    .bhd-mobile-header.scrolled {
        box-shadow: 0 4px 12px var(--bhd-shadow-md, rgba(0, 0, 0, 0.1));
    }

    /* ============================================
       COMPACT PROFILE
       ============================================ */

    .bhd-compact-profile {
        display: flex;
        align-items: center;
        gap: 12px;
        margin-bottom: 12px;
        padding: 0 16px;
        /* Add padding here instead */
        overflow: visible !important;
        /* Allow glow and frame to show */
    }

    /* Avatar */
    .bhd-avatar-small {
        position: relative;
        width: 48px;
        height: 48px;
        border-radius: 0;
        /* Don't clip - let avatar img handle rounding */
        overflow: visible !important;
        /* Allow glow and frame to show outside */
        flex-shrink: 0;
        box-shadow: none;
        /* Shadow on avatar img instead */
    }

    .bhd-avatar-small img.avatar {
        width: 100%;
        height: 100%;
        object-fit: cover;
        display: block;
        border-radius: 50%;
        position: relative;
        z-index: 2;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }

    /* Avatar Frame Overlay */
    .bhd-avatar-small .bhd-avatar-frame {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 100% !important;
        object-fit: cover !important;
        z-index: 4 !important;
        pointer-events: none !important;
        border-radius: 0 !important;
    }

    /* Avatar Glow Effect - Enhanced */
    .bhd-avatar-small .bhd-avatar-glow {
        position: absolute !important;
        inset: -6px !important;
        border-radius: 50% !important;
        background: linear-gradient(var(--rank-gradient)) !important;
        filter: blur(8px) !important;
        opacity: 0.7 !important;
        z-index: 1 !important;
        animation: pulse-glow 2s ease-in-out infinite !important;
    }

    /* Rank Indicator */
    .bhd-rank-indicator {
        position: absolute;
        bottom: -2px;
        right: -2px;
        width: 10px;
        height: 10px;
        border-radius: 50%;
        background: linear-gradient(135deg, #ffd700, #ffed4e);
        border: 2px solid white;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
        z-index: 5;
    }

    /* Rank-specific colors for indicator */
    [data-rank="rookie"] .bhd-rank-indicator {
        background: linear-gradient(135deg, #4ade80, #22c55e);
    }

    [data-rank="fighter"] .bhd-rank-indicator {
        background: linear-gradient(135deg, #60a5fa, #3b82f6);
    }

    [data-rank="captain"] .bhd-rank-indicator {
        background: linear-gradient(135deg, #a78bfa, #8b5cf6);
    }

    [data-rank="shichibukai"] .bhd-rank-indicator {
        background: linear-gradient(135deg, #f472b6, #ec4899);
    }

    [data-rank="yonko"] .bhd-rank-indicator {
        background: linear-gradient(135deg, #fbbf24, #f59e0b);
    }

    /* Rank-specific gradients for glow (matching desktop) */
    [data-rank="rookie"] {
        --rank-gradient: 135deg, #4ade80, #22c55e;
    }

    [data-rank="fighter"] {
        --rank-gradient: 135deg, #60a5fa, #3b82f6;
    }

    [data-rank="captain"] {
        --rank-gradient: 135deg, #a78bfa, #8b5cf6;
    }

    [data-rank="shichibukai"] {
        --rank-gradient: 135deg, #f472b6, #ec4899;
    }

    [data-rank="yonko"] {
        --rank-gradient: 135deg, #fbbf24, #f59e0b;
    }

    /* Pulse Glow Animation */
    @keyframes pulse-glow {

        0%,
        100% {
            opacity: 0.5;
            transform: scale(1);
        }

        50% {
            opacity: 0.7;
            transform: scale(1.05);
        }
    }

    /* Balance Section */
    .bhd-balance-compact {
        flex: 1;
        display: flex;
        flex-direction: column;
        gap: 2px;
        min-width: 0;
        /* Allow text truncation */
    }

    .bhd-balance-label {
        font-size: 11px;
        color: var(--bhd-text-secondary, #6B7280);
        font-weight: 500;
        letter-spacing: 0.3px;
        text-transform: uppercase;
    }

    .bhd-balance-value {
        font-size: 18px;
        font-weight: 700;
        color: var(--bhd-accent-primary, #D6546D);
        line-height: 1.2;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Quick Topup Button */
    .bhd-topup-quick-btn {
        padding: 10px 20px;
        background: var(--bhd-accent-primary, #D6546D);
        color: white;
        border: none;
        border-radius: 20px;
        font-size: 13px;
        font-weight: 600;
        white-space: nowrap;
        cursor: pointer;
        transition: all 0.2s ease;
        box-shadow: 0 2px 8px rgba(214, 84, 109, 0.3);
        /* Use transform for better performance */
        transform: scale(1);
        text-decoration: none;
        display: inline-block;
    }

    .bhd-topup-quick-btn:active {
        transform: scale(0.95);
    }

    .bhd-topup-quick-btn:hover {
        background: var(--bhd-accent-hover, #C04458);
        box-shadow: 0 4px 12px rgba(214, 84, 109, 0.4);
    }

    /* ============================================
       HORIZONTAL TABS - FIXED OVERFLOW
       ============================================ */

    .bhd-tabs-container {
        position: relative;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        /* Firefox */
        -ms-overflow-style: none;
        /* IE/Edge */
        margin: 0;
        /* No negative margin */
        padding: 0 16px 8px 16px;
        /* Padding inside instead */
    }

    /* Hide scrollbar */
    .bhd-tabs-container::-webkit-scrollbar {
        display: none;
    }

    .bhd-tabs-scroll {
        display: flex;
        gap: 8px;
        position: relative;
        padding-top: 4px;
        padding-bottom: 4px;
    }

    /* Individual Tab */
    .bhd-tab {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        padding: 10px 16px;
        background: var(--bhd-bg-hover, #F9FAFB);
        border-radius: 12px;
        text-decoration: none;
        color: var(--bhd-text-secondary, #6B7280);
        font-size: 12px;
        font-weight: 500;
        white-space: nowrap;
        flex-shrink: 0;
        /* Prevent shrinking */
        min-width: 80px;
        /* Minimum tap target */
        min-height: 44px;
        /* iOS recommended tap target */
        transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
        position: relative;
        user-select: none;
        -webkit-user-select: none;
        -webkit-tap-highlight-color: transparent;
    }

    /* Tab Icon */
    .bhd-tab .dashicons {
        font-size: 20px;
        width: 20px;
        height: 20px;
        line-height: 1;
        transition: transform 0.2s ease;
    }

    /* Active Tab */
    .bhd-tab.active {
        background: var(--bhd-accent-primary, #D6546D);
        color: white !important;
        box-shadow: 0 2px 8px rgba(214, 84, 109, 0.3);
        transform: translateY(-2px);
    }

    .bhd-tab.active span {
        color: white !important;
    }

    .bhd-tab.active .dashicons {
        color: white !important;
        transform: scale(1.1);
    }

    /* Tap feedback */
    .bhd-tab:active {
        transform: scale(0.95);
    }

    .bhd-tab.active:active {
        transform: translateY(-2px) scale(0.95);
    }

    /* ============================================
       CONTENT ADJUSTMENTS
       ============================================ */

    .bhd-mobile-content {
        padding: 0 16px;
    }

    /* Ensure stats cards work well on mobile */
    .bhd-stats-cards {
        margin-bottom: 24px;
    }
}

/* ============================================
   SMALLER MOBILE (<768px)
   ============================================ */

@media (max-width: 768px) {
    .bhd-mobile-header {
        padding: 10px 0 6px 0;
        margin: -20px 0 16px 0;
    }

    .bhd-compact-profile {
        gap: 10px;
        margin-bottom: 10px;
        padding: 0 12px;
        /* Smaller padding on small screens */
    }

    .bhd-avatar-small {
        width: 44px;
        height: 44px;
    }

    .bhd-balance-value {
        font-size: 16px;
    }

    .bhd-topup-quick-btn {
        padding: 8px 16px;
        font-size: 12px;
    }

    .bhd-tabs-container {
        margin-top: 25px;
        padding: 0 12px 8px 12px;
        /* Match compact-profile padding */
    }

    .bhd-tab {
        min-width: 70px;
        padding: 8px 12px;
        font-size: 11px;
    }

    .bhd-tab .dashicons {
        font-size: 18px;
        width: 18px;
        height: 18px;
    }
}

/* ============================================
   DARK MODE SUPPORT
   ============================================ */

[data-theme="dark"] .bhd-mobile-header {
    background: var(--bhd-bg-secondary, #1e293b);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .bhd-mobile-header.scrolled {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .bhd-tab {
    background: var(--bhd-bg-hover, #334155);
    color: var(--bhd-text-secondary, #cbd5e1);
}

[data-theme="dark"] .bhd-tab.active {
    background: var(--bhd-accent-primary, #D6546D);
    color: white !important;
}

[data-theme="dark"] .bhd-tab.active span {
    color: white !important;
}

[data-theme="dark"] .bhd-tab.active .dashicons {
    color: white !important;
}

/* ============================================
   ACCESSIBILITY
   ============================================ */

/* Focus states for keyboard navigation */
.bhd-tab:focus-visible {
    outline: 2px solid var(--bhd-accent-primary, #D6546D);
    outline-offset: 2px;
}

.bhd-topup-quick-btn:focus-visible {
    outline: 2px solid white;
    outline-offset: 2px;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {

    .bhd-mobile-header,
    .bhd-tab,
    .bhd-topup-quick-btn {
        transition: none !important;
        animation: none !important;
    }
}