/* Header Styles */
.site-header {
    background-color: transparent;
    color: var(--text-primary);
    padding: 12px 0;
    box-shadow: 0 4px 15px rgba(23, 33, 43, 0.3);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    max-height: 76px;
    width: 100%;
    backdrop-filter: blur(70px);
    -webkit-backdrop-filter: blur(70px);
}

.site-branding {
    position: relative;
    z-index: 2;
    width: 100%;
}

/* Desktop Header Navigation */
.desktop-header .header-navigation {
    flex: 0 0 auto;
    order: 2;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    direction: rtl;
}

.desktop-header .site-logo {
    margin-right: 0;
    margin-left: 0px;
    order: 3;
}

/* Desktop Header Icons Container - Always Left of Navigation */
.desktop-header .header-icons-left {
    order: 1;
    margin-right: auto;
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Header Login Buttons */
.header-login-btn {
    padding: 8px 16px;
    border-radius: 12px;
    text-decoration: none !important;
    font-size: 0.9em;
    font-weight: 500;
    transition: all 0.3s ease;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    border: 1px solid transparent;
}

/* Primary Login Button (New Panel) */
.header-login-btn.primary {
    background: var(--accent-primary);
    color: #FFFFFF;
    border-color: var(--accent-primary);
}

.header-login-btn.primary:hover {
    background: #2563eb;
    border-color: #2563eb;
    color: #FFFFFF;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(61, 114, 254, 0.3);
}

/* Secondary Login Button (Old Panel) */
.header-login-btn.secondary {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid rgba(33, 51, 100, 0.2);
}

.header-login-btn.secondary:hover {
    background: rgba(33, 51, 100, 0.1);
    color: var(--text-primary);
    border-color: rgba(33, 51, 100, 0.3);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(33, 51, 100, 0.15);
}

/* Download App Button */
.header-download-wrapper {
    position: relative;
    display: inline-block;
}

.header-download-btn {
    width: 40px;
    height: 40px;
    background: #cad8ff;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none !important;
    transition: all 0.3s ease;
    border: 1px solid rgba(71, 71, 71, 0.1);
    cursor: pointer;
}

.header-download-btn svg {
    color: #474747;
    transition: all 0.3s ease;
}

.header-download-btn:hover {
    background: #b8c9ff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(202, 216, 255, 0.4);
}

.header-download-btn:hover svg {
    color: #333333;
    transform: scale(1.1);
}

/* QR Code Popup */
.qr-popup {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    box-shadow: var(--shadow-card);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    z-index: 1000;
    min-width: 200px;
    text-align: center;
    direction: rtl;
}

.header-download-wrapper:hover .qr-popup {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.qr-popup-content h4 {
    margin: 0 0 15px 0;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 600;
}

.qr-code-container {
    margin: 15px 0;
    display: flex;
    justify-content: center;
}

.qr-code-container img {
    border-radius: 8px;
    background: white;
    padding: 8px;
    border: 1px solid var(--border-color);
}

.qr-popup-content p {
    margin: 10px 0 15px 0;
    color: var(--text-secondary);
    font-size: 12px;
}

.app-store-links {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 15px;
}

.app-store-links a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--bg-primary);
    border-radius: 8px;
    transition: all 0.3s ease;
    border: 1px solid var(--border-color);
}

.app-store-links a:hover {
    background: var(--accent-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(61, 114, 254, 0.3);
}

.app-store-links a img {
    width: 16px;
    height: 16px;
    /* Remove filter to keep original icon colors */
}

/* Dark theme styles for QR popup */
[data-theme="dark"] .qr-popup {
    background: var(--card-bg);
    border-color: var(--border-color);
    box-shadow: var(--shadow-card);
}

/* Remove dark theme icon filter to keep original colors */

/* Dark theme styles for header buttons */
[data-theme="dark"] .header-login-btn.secondary {
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.2);
}

[data-theme="dark"] .header-login-btn.secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
    color: var(--text-primary);
    box-shadow: 0 2px 8px rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .theme-toggle {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

[data-theme="dark"] .theme-toggle:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
    box-shadow: 0 2px 8px rgba(255, 255, 255, 0.1);
}

/* Auto dark theme support - only when no explicit theme is set */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) .header-login-btn.secondary {
        color: var(--text-primary);
        border-color: rgba(255, 255, 255, 0.2);
    }
    
    :root:not([data-theme]) .header-login-btn.secondary:hover {
        background: rgba(255, 255, 255, 0.1);
        border-color: rgba(255, 255, 255, 0.3);
        color: var(--text-primary);
        box-shadow: 0 2px 8px rgba(255, 255, 255, 0.1);
    }
    
    :root:not([data-theme]) .theme-toggle {
        background: rgba(255, 255, 255, 0.1);
        border-color: rgba(255, 255, 255, 0.2);
    }
    
    :root:not([data-theme]) .theme-toggle:hover {
        background: rgba(255, 255, 255, 0.15);
        border-color: rgba(255, 255, 255, 0.3);
        box-shadow: 0 2px 8px rgba(255, 255, 255, 0.1);
    }
}

/* Theme Toggle Button */
.theme-toggle {
    background: rgba(33, 51, 100, 0.1);
    border: 2px solid rgba(33, 51, 100, 0.2);
    border-radius: 50px;
    width: 50px;
    height: 26px;
    cursor: pointer;
    position: relative;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    padding: 2px;
}

.theme-toggle:hover {
    background: rgba(33, 51, 100, 0.15);
    border-color: rgba(33, 51, 100, 0.3);
    box-shadow: 0 2px 8px rgba(33, 51, 100, 0.2);
}

.theme-toggle-slider {
    width: 20px;
    height: 20px;
    background: var(--text-primary);
    border-radius: 50%;
    transition: all 0.3s ease;
    transform: translateX(0);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.theme-toggle.dark .theme-toggle-slider {
    transform: translateX(22px);
    background: var(--accent-primary);
}

.theme-toggle-icon {
    transition: all 0.3s ease;
}

/* Theme Toggle Icons */
.theme-toggle .sun-icon {
    opacity: 1;
}

.theme-toggle .moon-icon {
    opacity: 0;
    position: absolute;
}

.theme-toggle.dark .sun-icon {
    opacity: 0;
}

.theme-toggle.dark .moon-icon {
    opacity: 1;
}

.header-navigation ul {
    list-style: none;
    display: flex;
    gap: 20px;
    margin: 0;
    padding: 0;
}

.header-navigation li {
    margin: 0;
    position: relative;
}

.header-navigation a {
    color: var(--text-primary);
    text-decoration: none !important;
    padding: 8px 16px;
    border-radius: 20px;
    border-bottom: 2px solid transparent;
    transition: all 0.3s ease;
    font-weight: 500;
    font-size: 0.95em;
    white-space: nowrap;
    display: block;
}

.header-navigation a:hover {
    background: rgba(33, 51, 100, 0.1);
    color: var(--text-primary);
    text-decoration: none !important;
}

.header-navigation .current-menu-item a,
.header-navigation .current_page_item a {
    background: rgba(33, 51, 100, 0.15);
    color: var(--text-primary);
}

/* Submenu Styles */
.header-navigation .sub-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--header-bg);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0 0 8px 8px;
    border-top: 2px solid var(--accent-primary);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
    min-width: 200px;
    max-width: 400px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    z-index: 1000;
    padding: 8px 0;
    margin-top: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
}

.header-navigation .sub-menu li {
    margin: 0;
    display: block;
    width: 100%;
}

.header-navigation .sub-menu a {
    padding: 12px 20px;
    border-radius: 0;
    font-size: 0.9em;
    font-weight: 400;
    white-space: nowrap;
    display: block;
    width: 100%;
    text-decoration: none !important;
}

.header-navigation .sub-menu a:hover {
    background: rgba(33, 51, 100, 0.1);
    color: var(--text-primary);
    text-decoration: none !important;
}


/* Single column only for submenus with exactly 1 item */
.header-navigation .sub-menu:not(:has(li:nth-child(2))) {
    grid-template-columns: 1fr;
    max-width: 200px;
}

/* Ensure proper spacing for two-column layout (2+ items, including 3 items like staking) */
.header-navigation .sub-menu:has(li:nth-child(2)) li:nth-child(odd) {
    padding-right: 8px;
}

.header-navigation .sub-menu:has(li:nth-child(2)) li:nth-child(even) {
    padding-left: 8px;
}

/* Hover effect to show submenu */
.header-navigation li:hover .sub-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Keep parent item highlighted when dropdown is open */
.header-navigation li:hover > a,
.header-navigation li.menu-item-has-children:hover > a {
    background: rgba(33, 51, 100, 0.1);
    color: var(--text-primary);
    text-decoration: none !important;
}

/* Enhanced hover state for parent items with dropdowns */
.header-navigation .menu-item-has-children:hover > a {
    background: rgba(33, 51, 100, 0.15);
    box-shadow: 0 2px 8px rgba(33, 51, 100, 0.2);
    border-bottom: 2px solid var(--accent-primary);
    border-radius: 20px 20px 0 0;
}

/* Maintain parent highlight while dropdown is open */
.header-navigation .menu-item-has-children:hover > a::after {
    color: var(--accent-primary);
    transform: rotate(180deg);
}

/* Smooth transition for parent item states */
.header-navigation .menu-item-has-children > a {
    border-bottom: 2px solid transparent;
    transition: all 0.3s ease, border-bottom 0.2s ease;
}

/* Dark theme specific styles for dropdown parent highlighting */
[data-theme="dark"] .header-navigation a:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

[data-theme="dark"] .header-navigation .current-menu-item a,
[data-theme="dark"] .header-navigation .current_page_item a {
    background: rgba(255, 255, 255, 0.15);
    color: var(--text-primary);
}

[data-theme="dark"] .header-navigation li:hover > a,
[data-theme="dark"] .header-navigation li.menu-item-has-children:hover > a {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

[data-theme="dark"] .header-navigation .menu-item-has-children:hover > a {
    background: rgba(255, 255, 255, 0.15);
    box-shadow: 0 2px 8px rgba(255, 255, 255, 0.1);
    border-bottom: 2px solid var(--accent-primary);
}

[data-theme="dark"] .header-navigation .sub-menu a:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

[data-theme="dark"] .header-navigation .sub-menu {
    border-top: 2px solid var(--accent-primary);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.5);
}

/* Auto dark theme support - only when no explicit theme is set */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) .header-navigation a:hover {
        background: rgba(255, 255, 255, 0.1);
        color: var(--text-primary);
    }
    
    :root:not([data-theme]) .header-navigation .current-menu-item a,
    :root:not([data-theme]) .header-navigation .current_page_item a {
        background: rgba(255, 255, 255, 0.15);
        color: var(--text-primary);
    }
    
    :root:not([data-theme]) .header-navigation li:hover > a,
    :root:not([data-theme]) .header-navigation li.menu-item-has-children:hover > a {
        background: rgba(255, 255, 255, 0.1);
        color: var(--text-primary);
    }
    
    :root:not([data-theme]) .header-navigation .menu-item-has-children:hover > a {
        background: rgba(255, 255, 255, 0.15);
        box-shadow: 0 2px 8px rgba(255, 255, 255, 0.1);
        border-bottom: 2px solid var(--accent-primary);
    }
    
    :root:not([data-theme]) .header-navigation .sub-menu a:hover {
        background: rgba(255, 255, 255, 0.1);
        color: var(--text-primary);
    }
    
    :root:not([data-theme]) .header-navigation .sub-menu {
        border-top: 2px solid var(--accent-primary);
        box-shadow: 0 8px 25px rgba(0, 0, 0, 0.5);
    }
}

/* Arrow indicator for parent items */
.header-navigation .menu-item-has-children>a::after {
    content: '▼';
    margin-right: 6px;
    font-size: 0.7em;
    transition: transform 0.3s ease;
}

.header-navigation .menu-item-has-children:hover>a::after {
    transform: rotate(180deg);
}


.site-logo-img {
    height: 48px;
    width: auto;
    /*max-width: 180px;*/
    transition: all 0.3s ease, opacity 0.2s ease;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.2));
}

.logo-link {
    display: block;
    text-decoration: none;
}

.logo-link:hover .site-logo-img {
    transform: scale(1);
    filter: drop-shadow(0 4px 12px rgba(61, 114, 254, 0.4));
}

.site-title {
    font-size: 2em;
    margin-bottom: 5px;
    font-weight: 600;
    color: var(--text-primary);
}

.site-description {
    font-size: 0.95em;
    color: var(--text-secondary);
    font-weight: 300;
    line-height: 1.2;
}

/* Mobile Menu Styles */
.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 40px;
    height: 40px;
    border-radius: 6px;
    transition: all 0.3s ease;
}

.mobile-menu-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
}

.hamburger-line {
    width: 24px;
    height: 2px;
    background: var(--text-primary);
    margin: 3px 0;
    transition: all 0.3s ease;
    border-radius: 2px;
}

.mobile-menu-toggle.active .hamburger-line:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.mobile-menu-toggle.active .hamburger-line:nth-child(2) {
    opacity: 0;
}

.mobile-menu-toggle.active .hamburger-line:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -6px);
}

/* Mobile Menu Overlay */
.mobile-menu-overlay {
    position: fixed;
    top: 0;
    right: -100%;
    width: 100%;
    height: 100vh; /* Fallback for older browsers */
    height: 100dvh; /* Dynamic viewport height - accounts for browser UI */
    background: var(--header-bg);
    z-index: 9999;
    transition: right 0.3s ease;
    overflow: hidden;
}

.mobile-menu-overlay.active {
    right: 0;
}

.mobile-menu-content {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
}

.mobile-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    background: var(--header-bg);
    position: sticky;
    top: 0;
    z-index: 10;
    flex-shrink: 0;
}

.mobile-menu-logo {
    flex: 1;
}

.mobile-menu-logo .site-logo-img {
    height: 60px;
    width: auto;
}

.mobile-menu-close {
    background: none;
    border: none;
    font-size: 32px;
    color: var(--text-primary);
    cursor: pointer;
    padding: 5px;
    line-height: 1;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.mobile-menu-close:hover {
    background: rgba(255, 255, 255, 0.1);
}

.mobile-menu-body {
    flex: 1;
    padding: 20px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px) + var(--mobile-menu-extra-padding, 30px)); /* Extra padding for system UI and download button */
    display: flex;
    flex-direction: column;
    gap: 30px;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
    /* Enable smooth scrolling */
    -webkit-overflow-scrolling: touch;
}

/* Mobile Theme Toggle */
.mobile-menu-section {
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 20px;
}

.mobile-theme-toggle {
    display: flex;
    align-items: center;
    gap: 15px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 15px 20px;
    width: 100%;
    cursor: pointer;
    transition: all 0.3s ease;
    color: var(--text-primary);
    font-size: 16px;
}

.mobile-theme-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
}

.mobile-theme-icon {
    font-size: 24px;
}

.mobile-theme-text {
    font-weight: 500;
}

/* Mobile Navigation */
.mobile-navigation {
    flex: 1;
}

.mobile-navigation ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.mobile-navigation li {
    margin: 0;
    border-bottom: 1px solid var(--border-color);
}

.mobile-navigation li:last-child {
    border-bottom: none;
}

.mobile-navigation a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    color: var(--text-primary);
    text-decoration: none !important;
    font-size: 18px;
    font-weight: 500;
    transition: all 0.3s ease;
    border: none;
    border-radius: 0;
    background: transparent;
}

.mobile-navigation a:hover {
    background: rgba(255, 255, 255, 0.1);
    text-decoration: none !important;
}

.mobile-navigation .current-menu-item a,
.mobile-navigation .current_page_item a {
    background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
    color: #FFFFFF;
}

/* Override current-menu-item color for accordion items when closed */
.mobile-navigation .menu-item-has-children:not(.menu-open).current-menu-item > a,
.mobile-navigation .menu-item-has-children:not(.menu-open).current_page_item > a {
    color: var(--text-primary) !important;
    background: transparent !important;
}

/* Parent menu items with children */
.mobile-navigation .menu-item-has-children > a {
    position: relative;
}

/* New accordion toggle icon (SVG based like footer) */
.mobile-navigation .accordion-toggle {
    color: var(--text-secondary);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
    margin-left: 8px;
}

/* Legacy arrow support */
.mobile-navigation .menu-item-has-children > a::after {
    content: '▼';
    font-size: 14px;
    transition: transform 0.3s ease;
    color: var(--text-secondary);
}

.mobile-navigation .menu-item-has-children.menu-open > a::after {
    transform: rotate(180deg);
    color: var(--accent-primary);
}

/* Keep parent item highlighted when submenu is visible in mobile */
.mobile-navigation .menu-item-has-children:hover > a,
.mobile-navigation .menu-item-has-children.menu-open > a {
    background: transparent !important;
    text-decoration: none !important;
}

/* Change text color when accordion is open */
.mobile-navigation .menu-item-has-children.menu-open > a {
    color: var(--accent-primary) !important;
    transition: color 0.3s ease;
}

/* Exception: Don't change color for theme toggle menu item */
.mobile-navigation a[href="#theme-toggle"] {
    color: var(--text-primary) !important;
}

/* Reset text color when accordion is closed (not open) */
.mobile-navigation .menu-item-has-children:not(.menu-open) > a {
    color: var(--text-primary) !important;
    background: transparent !important;
    transition: color 0.3s ease;
}

/* Mobile Submenu */
.mobile-navigation .sub-menu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1), 
                opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), 
                padding 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: transparent;
    border-top: none;
    margin: 0;
    padding: 0;
    opacity: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
}

/* Active state for submenu (based on footer accordion approach) */
.mobile-navigation .sub-menu.active {
    max-height: 500px; /* Adjust based on content */
    padding: 10px;
    opacity: 1;
}

/* Legacy support for old classes */
.mobile-navigation .sub-menu.open {
    padding: 10px;
}

.mobile-navigation .menu-item-has-children.menu-open .sub-menu {
    max-height: 500px; /* Adjust based on content */
    padding: 10px;
}

.mobile-navigation .sub-menu li {
    border-bottom: none;
    margin: 0;
    display: flex;
    flex-direction: column;
}

/* Remove border from last two items in each row */
.mobile-navigation .sub-menu li:nth-last-child(-n+2) {
    border-bottom: none;
}

/* Add right border to odd items (left column) */
.mobile-navigation .sub-menu li:nth-child(odd) {
    border-left: none;
}

.mobile-navigation .sub-menu a {
    padding: 15px 10px;
    font-size: 14px;
    font-weight: 400;
    opacity: 0.9;
    text-decoration: none !important;
    border-radius: 0;
    border-right: 2px solid var(--accent-primary);
    margin-right: 4px;
    text-align: center;
    display: flex;
    align-items: center;
    word-wrap: break-word;
    hyphens: auto;
}

.mobile-navigation .sub-menu a::after {
    display: none;
}

.mobile-navigation .sub-menu a:hover {
    background: transparent;
    opacity: 1;
}

/* Dark theme specific styles for mobile navigation */
[data-theme="dark"] .mobile-navigation a:hover {
    background: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .mobile-navigation .menu-item-has-children:hover > a,
[data-theme="dark"] .mobile-navigation .menu-item-has-children.menu-open > a {
    background: transparent !important;
}

[data-theme="dark"] .mobile-navigation .menu-item-has-children.menu-open > a {
    color: var(--accent-primary) !important;
}

/* Exception: Don't change color for theme toggle menu item in dark theme */
[data-theme="dark"] .mobile-navigation a[href="#theme-toggle"] {
    color: var(--text-primary) !important;
}

[data-theme="dark"] .mobile-navigation .menu-item-has-children:not(.menu-open) > a {
    color: var(--text-primary) !important;
    background: transparent !important;
}

/* Override current-menu-item color for accordion items when closed in dark theme */
[data-theme="dark"] .mobile-navigation .menu-item-has-children:not(.menu-open).current-menu-item > a,
[data-theme="dark"] .mobile-navigation .menu-item-has-children:not(.menu-open).current_page_item > a {
    color: var(--text-primary) !important;
    background: transparent !important;
}

[data-theme="dark"] .mobile-navigation .sub-menu {
    background: transparent;
}

[data-theme="dark"] .mobile-navigation .sub-menu a:hover {
    background: transparent;
}

/* Auto dark theme support for mobile navigation - only when no explicit theme is set */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) .mobile-navigation a:hover {
        background: rgba(255, 255, 255, 0.1);
    }
    
    :root:not([data-theme]) .mobile-navigation .menu-item-has-children:hover > a,
    :root:not([data-theme]) .mobile-navigation .menu-item-has-children.menu-open > a {
        background: transparent !important;
    }
    
    :root:not([data-theme]) .mobile-navigation .menu-item-has-children.menu-open > a {
        color: var(--accent-primary) !important;
    }
    
    /* Exception: Don't change color for theme toggle menu item in auto dark theme */
    :root:not([data-theme]) .mobile-navigation a[href="#theme-toggle"] {
        color: var(--text-primary) !important;
    }
    
    :root:not([data-theme]) .mobile-navigation .menu-item-has-children:not(.menu-open) > a {
        color: var(--text-primary) !important;
        background: transparent !important;
    }
    
    /* Override current-menu-item color for accordion items when closed in auto dark theme */
    :root:not([data-theme]) .mobile-navigation .menu-item-has-children:not(.menu-open).current-menu-item > a,
    :root:not([data-theme]) .mobile-navigation .menu-item-has-children:not(.menu-open).current_page_item > a {
        color: var(--text-primary) !important;
        background: transparent !important;
    }
    
    :root:not([data-theme]) .mobile-navigation .sub-menu {
        background: transparent;
    }
    
    :root:not([data-theme]) .mobile-navigation .sub-menu a:hover {
        background: transparent;
    }
}

/* Theme Toggle Button in Mobile Menu */
.mobile-navigation .mobile-menu-theme-toggle {
    flex-shrink: 0;
    margin-right: 0;
    margin-left: auto;
    direction: ltr;
}

.mobile-navigation a[href="#theme-toggle"] {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    width: 100% !important;
}

.mobile-navigation a[href="#theme-toggle"] > span:first-child {
    flex: 1;
    margin-left: 0;
}

.mobile-navigation a[href="#theme-toggle"]:hover .mobile-menu-theme-toggle {
    background: rgba(33, 51, 100, 0.15);
    border-color: rgba(33, 51, 100, 0.3);
    box-shadow: 0 2px 8px rgba(33, 51, 100, 0.2);
}

[data-theme="dark"] .mobile-navigation a[href="#theme-toggle"]:hover .mobile-menu-theme-toggle {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
    box-shadow: 0 2px 8px rgba(255, 255, 255, 0.1);
}

/* Two-column layout improvements */
/* Improve visual separation between columns */
.mobile-navigation .sub-menu li:nth-child(even) {
    border-right: none;
}

/* Better spacing for two-column layout */
.mobile-navigation .sub-menu a {
    margin: 3px;
    border-radius: 0;
    transition: all 0.2s ease;
}

/* Responsive behavior for very small screens */
@media (max-width: 320px) {
    .mobile-navigation .sub-menu {
        grid-template-columns: 1fr;
    }
    
    .mobile-navigation .sub-menu li:nth-child(odd) {
        border-left: none;
    }
    
    .mobile-navigation .sub-menu li:nth-child(even) {
        border-right: none;
    }
    
    .mobile-navigation .sub-menu li:nth-last-child(-n+2) {
        border-bottom: none;
    }
    
    .mobile-navigation .sub-menu li:last-child {
        border-bottom: none;
    }
}

/* Mobile Action Buttons */
.mobile-menu-actions {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: auto;
    padding-top: 20px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px) + var(--mobile-menu-extra-padding, 0px)); /* Safe area for iOS and Android */
    border-top: 1px solid var(--border-color);
    /* Ensure actions are always visible */
    position: relative;
    z-index: 1;
}

/* Login buttons container - two buttons in one row */
.mobile-menu-actions .login-buttons-row {
    display: flex;
    gap: 10px;
    width: 100%;
}

.mobile-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    padding: 18px 20px;
    border-radius: 12px;
    text-decoration: none;
    font-size: 16px;
    font-weight: 500;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    box-sizing: border-box;
}

/* Login buttons - 50% width each when in row */
.mobile-action-btn.login-btn {
    flex: 1;
    min-width: 0; /* Allow shrinking */
}

/* Download button - full width (moved to main definition below) */

.mobile-action-btn.login-btn.primary {
    background: var(--accent-primary);
    color: #FFFFFF;
    text-decoration: none;
}

.mobile-action-btn.login-btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(61, 114, 254, 0.3);
}

.mobile-action-btn.login-btn.secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    text-decoration: none;
    border-color: var(--border-color);
}

.mobile-action-btn.login-btn.secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent-primary);
}

.mobile-action-btn.download-btn {
    background: var(--accent-secondary);
    color: #fff;
    text-decoration: none;
    border-color: var(--border-color);
    width: 100%;
    /* Ensure same height as login buttons */
    padding: 18px 20px;
    box-sizing: border-box;
}

.mobile-action-btn.download-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent-primary);
}

.btn-text {
    flex: 1;
    text-align: center;
}

/* Responsive adjustments for all mobile action buttons */
@media (max-width: 480px) {
    .login-buttons-row {
        gap: 8px;
    }
    
    .mobile-action-btn.login-btn,
    .mobile-action-btn.download-btn {
        padding: 16px 12px;
        font-size: 14px;
    }
    
    .mobile-action-btn.login-btn .btn-text,
    .mobile-action-btn.download-btn .btn-text {
        font-size: 13px;
        line-height: 1.2;
    }
}

@media (max-width: 360px) {
    .login-buttons-row {
        gap: 6px;
    }
    
    .mobile-action-btn.login-btn,
    .mobile-action-btn.download-btn {
        padding: 14px 8px;
        font-size: 13px;
    }
    
    .mobile-action-btn.login-btn .btn-text,
    .mobile-action-btn.download-btn .btn-text {
        font-size: 12px;
    }
}

/* Desktop Only Elements */
.desktop-only {
    display: flex;
}

/* Mobile Only Elements */
.mobile-only {
    display: none;
}

/* Hide mobile elements on desktop */
@media (min-width: 769px) {
    .mobile-header,
    .mobile-header-right,
    .mobile-header-left,
    .mobile-logo,
    .mobile-login-btn,
    .mobile-menu-toggle {
        display: none !important;
    }
}

/* Desktop Header Layout */
.desktop-header {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    flex-wrap: wrap;
    position: relative;
    z-index: 2;
    width: 100%;
    padding: 0 40px;
    max-width: none;
    margin: 0;
    gap: 15px;
    direction: ltr;
}

/* Mobile Header Layout */
.mobile-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 0 20px;
    direction: rtl;
    min-height: 60px;
    overflow: hidden;
}

.mobile-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
    order: 1;
    flex: 1;
    min-width: 0; /* Allow shrinking */
}

.mobile-header-left {
    display: flex;
    align-items: center;
    gap: 6px;
    order: 2;
    flex-shrink: 0; /* Prevent shrinking */
}

/* Mobile Logo */
.mobile-logo {
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0; /* Allow shrinking */
}

.mobile-logo .site-logo-img {
    height: 50px;
    width: auto;
    object-fit: contain;
}

/* Mobile Login Buttons */
.mobile-login-btn {
    padding: 12px 14px;
    border-radius: 12px;
    text-decoration: none !important;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    border: 1px solid transparent;
    flex-shrink: 0;
}

/* Primary Mobile Login Button (New Panel) */
.mobile-login-btn.primary {
    background: var(--accent-primary);
    color: #FFFFFF;
    border-color: var(--accent-primary);
}

.mobile-login-btn.primary:hover {
    background: #2563eb;
    border-color: #2563eb;
    color: #FFFFFF;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(61, 114, 254, 0.3);
}

/* Responsive Design */
@media (max-width: 768px) {
    body {
        padding-top: 60px; /* Adjust for smaller mobile header */
    }
    
    .site-header {
        padding: 12px 0;
        max-height: 100px;
    }

    .site-branding {
        padding: 0;
        margin: 0;
        width: 100%;
    }

    /* Hide desktop elements on mobile */
    .desktop-only {
        display: none !important;
    }

    /* Show mobile elements */
    .mobile-only {
        display: flex !important;
    }

    /* Mobile Menu Toggle Styles */
    .mobile-menu-toggle {
        display: flex;
    }
}

/* Smaller mobile screens adjustments */
@media (max-width: 480px) {
    .mobile-header {
        padding: 0 12px;
    }
    
    .mobile-header-left {
        gap: 4px;
    }
    
    .mobile-header-right {
        gap: 10px;
    }
    
    .mobile-login-btn {
        padding: 10px 12px;
        font-size: 14px;
    }
    
    .mobile-logo .site-logo-img {
        height: 44px;
        width: auto;
        object-fit: contain;
    }
}

/* Extra small screens */
@media (max-width: 360px) {
    .mobile-header {
        padding: 0 8px;
    }
    
    .mobile-header-left {
        gap: 2px;
    }
    
    .mobile-header-right {
        gap: 8px;
    }
    
    .mobile-login-btn {
        padding: 8px 10px;
        font-size: 0.65em;
    }
    
    .mobile-logo .site-logo-img {
        height: 32px;
    }
}