.navbar {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    transition: transform 0.4s ease, opacity 0.4s ease;
}

.nav-inner {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border-radius: 50px;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--bg-glass-border);
    transition: background var(--transition), border-color var(--transition);
}

[data-theme="dark"] .nav-inner {
    background: rgba(10, 10, 18, 0.85);
}

[data-theme="light"] .nav-inner {
    background: rgba(255, 255, 255, 0.82);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
}

/* ============================================
   Nav Items — Text Only
   ============================================ */

/* ============================================
   Nav Items — Text Only
   ============================================ */

   .nav-items {
    display: flex;
    align-items: center;
    gap: 4px;
}

.nav-link {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    border-radius: 0;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    transition: color var(--transition);
    white-space: nowrap;
    user-select: none;
}

/* vertical divider */
.nav-link:not(:last-child)::after {
    content: '';
    position: absolute;
    inset-inline-start: 100%;
    top: 50%;
    transform: translateY(-50%);
    width: 1px;
    height: 60%;
    background: var(--bg-glass-border);
}

/* underline animation element */
.nav-link::before {
    content: '';
    position: absolute;
    bottom: 0;
    height: 2px;
    width: 0;
    background: var(--accent);
    transition: width 0.35s ease;
}

/* LTR animation: left → right */
html[dir="ltr"] .nav-link::before {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
}
html[dir="ltr"] .nav-link:hover::before,
html[dir="ltr"] .nav-link.active::before {
    width: 60%;
}

/* RTL animation: right → left */
html[dir="rtl"] .nav-link::before {
    right: auto;
    left: 50%;
    transform: translateX(-50%);
}
html[dir="rtl"] .nav-link:hover::before,
html[dir="rtl"] .nav-link.active::before {
    width: 60%;
}

/* hover */
.nav-link:hover {
    color: var(--text-primary);
    background: transparent;
}

/* active */
.nav-link.active {
    color: var(--accent);
    font-weight: 600;
    background: transparent;
}

[data-theme="light"] .nav-link.active {
    color: var(--accent);
}


.nav-link:hover {
    color: var(--text-primary);
    background: transparent;
}

.nav-link:hover::before {
    width: 100%;
    right: auto;
    left: 0;
}

/* Active State */
.nav-link.active {
    color: var(--accent);
    font-weight: 600;
    background: transparent;
}

.nav-link.active::before {
    width: 100%;
    right: auto;
    left: 0;
}

[data-theme="light"] .nav-link.active {
    color: var(--accent);
}

/* ============================================
   Nav Controls — Lang + Theme
   ============================================ */

.nav-controls {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-inline-start: 8px;
    padding-inline-start: 8px;
    border-inline-start: 1px solid var(--bg-glass-border);
}

/* Language Toggle */
.lang-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: transparent;
    cursor: pointer;
    transition: all var(--transition);
    font-family: 'Vazirmatn', sans-serif;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.02em;
}

.lang-toggle:hover {
    color: var(--text-primary);
}

[data-theme="dark"] .lang-toggle:hover {
    background: rgba(255, 255, 255, 0.06);
}

[data-theme="light"] .lang-toggle:hover {
    background: rgba(0, 0, 0, 0.04);
}

/* Theme Switch — Simple Icon Toggle */
.theme-switch {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: transparent;
    cursor: pointer;
    transition: all var(--transition);
    color: var(--text-secondary);
    padding: 0;
}

.theme-switch:hover {
    color: var(--text-primary);
}

[data-theme="dark"] .theme-switch:hover {
    background: rgba(255, 255, 255, 0.06);
}

[data-theme="light"] .theme-switch:hover {
    background: rgba(0, 0, 0, 0.04);
}

/* Show/hide sun & moon based on theme */
.theme-switch .icon-sun,
.theme-switch .icon-moon {
    transition: opacity 0.3s ease, transform 0.3s ease;
    position: absolute;
}

.theme-switch {
    position: relative;
    overflow: hidden;
}

.theme-switch .icon-sun,
.theme-switch .icon-moon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* Dark mode: show moon, hide sun */
[data-theme="dark"] .theme-switch .icon-sun {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(90deg) scale(0.5);
}

[data-theme="dark"] .theme-switch .icon-moon {
    opacity: 1;
    transform: translate(-50%, -50%) rotate(0deg) scale(1);
}

/* Light mode: show sun, hide moon */
[data-theme="light"] .theme-switch .icon-sun {
    opacity: 1;
    transform: translate(-50%, -50%) rotate(0deg) scale(1);
}

[data-theme="light"] .theme-switch .icon-moon {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(-90deg) scale(0.5);
}

/* ============================================
   Responsive
   ============================================ */

@media (max-width: 768px) {
    .navbar {
        bottom: 16px;
        left: 8px;
        right: 8px;
        transform: none;
    }

    .nav-inner {
        justify-content: center;
        padding: 6px 10px;
    }

    .nav-link {
        padding: 7px 10px;
        font-size: 0.78rem;
    }

    .nav-controls {
        margin-inline-start: 4px;
        padding-inline-start: 4px;
    }
}

@media (max-width: 480px) {
    .nav-link {
        padding: 6px 8px;
        font-size: 0.72rem;
    }

    .lang-toggle,
    .theme-switch {
        width: 32px;
        height: 32px;
    }

    .theme-switch .icon-sun,
    .theme-switch .icon-moon {
        width: 15px;
        height: 15px;
    }
}


/* ============================================
   Language Dropdown
   ============================================ */

   .lang-dropdown {
    position: relative;
}

.lang-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    width: auto;
    min-width: 80px;
    height: 36px;
    padding: 0 10px;
    border-radius: 18px;
    border: none;
    background: transparent;
    cursor: pointer;
    transition: all var(--transition);
    font-family: 'Vazirmatn', sans-serif;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.lang-toggle:hover {
    color: var(--text-primary);
}

[data-theme="dark"] .lang-toggle:hover {
    background: rgba(255, 255, 255, 0.06);
}

[data-theme="light"] .lang-toggle:hover {
    background: rgba(0, 0, 0, 0.04);
}

.lang-label {
    font-size: 0.8rem;
}

.lang-arrow {
    transition: transform 0.3s ease;
    opacity: 0.6;
}

.lang-dropdown.active .lang-arrow {
    transform: rotate(180deg);
}

.lang-menu {
    position: absolute;
    bottom: calc(100% + 12px);
    right: 0;
    min-width: 120px;
    padding: 6px;
    background: var(--card-bg);
    border: 1px solid var(--bg-glass-border);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.3s ease;
    z-index: 1000;
}

[data-theme="dark"] .lang-menu {
    background: rgba(20, 20, 30, 0.95);
    backdrop-filter: blur(20px);
}

[data-theme="light"] .lang-menu {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
}

.lang-dropdown.active .lang-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.lang-option {
    width: 100%;
    padding: 8px 12px;
    background: none;
    border: none;
    border-radius: 8px;
    text-align: right;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

.lang-option:hover {
    color: var(--text-primary);
    background: var(--hover-bg);
}

[data-theme="dark"] .lang-option:hover {
    background: rgba(255, 255, 255, 0.08);
}

[data-theme="light"] .lang-option:hover {
    background: rgba(0, 0, 0, 0.05);
}

/* RTL Support */
html[dir="rtl"] .lang-menu {
    right: auto;
    left: 0;
}

html[dir="rtl"] .lang-option {
    text-align: left;
}

/* ============================================
   Responsive — Improved Mobile Layout
   ============================================ */

   @media (max-width: 768px) {

    .navbar {
        bottom: 16px;
        left: 8px;
        right: 8px;
        transform: none;
    }

    .nav-inner {
        width: 100%;
        justify-content: space-between;
        padding: 6px 10px;
        gap: 4px;
    }

    /* Make nav items scrollable instead of squished */
    .nav-items {
        flex: 1;
        display: flex;
        align-items: center;
        gap: 2px;
        overflow-x: auto;
        scrollbar-width: none;
    }

    .nav-items::-webkit-scrollbar {
        display: none;
    }

    .nav-link {
        flex: 0 0 auto;
        padding: 6px 10px;
        font-size: 0.75rem;
        white-space: nowrap;
    }

    /* Remove dividers on mobile */
    .nav-link::after {
        display: none;
    }

    /* Controls tighter */
    .nav-controls {
        flex: 0 0 auto;
        margin-inline-start: 4px;
        padding-inline-start: 4px;
        gap: 2px;
    }

    .lang-toggle {
        min-width: auto;
        height: 32px;
        padding: 0 8px;
        font-size: 0.7rem;
    }

    .theme-switch {
        width: 32px;
        height: 32px;
    }

    .theme-switch .icon-sun,
    .theme-switch .icon-moon {
        width: 15px;
        height: 15px;
    }
}

@media (max-width: 480px) {

    .nav-link {
        padding: 5px 8px;
        font-size: 0.7rem;
    }

    .nav-inner {
        padding: 5px 8px;
    }

}


/* ============================================
   Navbar Mobile Fix — Final Override
   ============================================ */

   .navbar,
   .nav-inner,
   .nav-items,
   .nav-controls,
   .nav-link,
   .lang-toggle,
   .theme-switch,
   .lang-menu {
       box-sizing: border-box;
   }
   
   .navbar {
       max-width: calc(100vw - 16px);
   }
   
   .nav-inner {
       max-width: 100%;
       overflow: visible;
   }
   
   @media (max-width: 768px) {
       .navbar {
           position: fixed;
           bottom: max(12px, env(safe-area-inset-bottom));
           left: 8px;
           right: 8px;
           width: auto;
           max-width: calc(100vw - 16px);
           transform: none;
       }
   
       .nav-inner {
           width: 100%;
           max-width: 100%;
           min-width: 0;
           display: flex;
           align-items: center;
           justify-content: space-between;
           gap: 6px;
           padding: 6px 8px;
           border-radius: 999px;
           overflow: visible;
       }
   
       .nav-items {
           flex: 1 1 auto;
           min-width: 0;
           display: flex;
           align-items: center;
           gap: 2px;
           overflow-x: auto;
           overflow-y: hidden;
           scrollbar-width: none;
           -webkit-overflow-scrolling: touch;
       }
   
       .nav-items::-webkit-scrollbar {
           display: none;
       }
   
       .nav-link {
           flex: 0 0 auto;
           padding: 6px 9px;
           font-size: 0.72rem;
           line-height: 1;
           white-space: nowrap;
       }
   
       .nav-link::after {
           display: none;
       }
   
       .nav-link::before {
           bottom: -1px;
       }
   
       .nav-controls {
           flex: 0 0 auto;
           display: flex;
           align-items: center;
           gap: 2px;
           margin-inline-start: 4px;
           padding-inline-start: 4px;
           min-width: max-content;
       }
   
       .lang-toggle {
           width: auto;
           min-width: 52px;
           max-width: 68px;
           height: 32px;
           padding: 0 7px;
           gap: 3px;
           font-size: 0.68rem;
           border-radius: 999px;
           overflow: hidden;
       }
   
       .lang-label {
           max-width: 38px;
           overflow: hidden;
           text-overflow: ellipsis;
           white-space: nowrap;
           font-size: 0.68rem;
       }
   
       .lang-arrow {
           flex: 0 0 auto;
       }
   
       .theme-switch {
           flex: 0 0 auto;
           width: 32px;
           height: 32px;
           min-width: 32px;
           min-height: 32px;
       }
   
       .theme-switch .icon-sun,
       .theme-switch .icon-moon {
           width: 15px;
           height: 15px;
       }
   
       .lang-dropdown {
           position: relative;
       }
   
       .lang-menu {
           position: absolute;
           bottom: calc(100% + 10px);
           right: 0;
           left: auto;
           min-width: 110px;
           max-width: calc(100vw - 32px);
           z-index: 1002;
       }
   
       html[dir="rtl"] .lang-menu {
           right: auto;
           left: 0;
       }
   }
   
   @media (max-width: 480px) {
       .navbar {
           left: 6px;
           right: 6px;
           max-width: calc(100vw - 12px);
       }
   
       .nav-inner {
           padding: 5px 6px;
           gap: 4px;
       }
   
       .nav-link {
           padding: 6px 7px;
           font-size: 0.68rem;
       }
   
       .nav-controls {
           gap: 1px;
           margin-inline-start: 3px;
           padding-inline-start: 3px;
       }
   
       .lang-toggle {
           min-width: 46px;
           max-width: 58px;
           height: 30px;
           padding: 0 6px;
           font-size: 0.64rem;
       }
   
       .lang-label {
           max-width: 30px;
           font-size: 0.64rem;
       }
   
       .theme-switch {
           width: 30px;
           height: 30px;
           min-width: 30px;
           min-height: 30px;
       }
   }
   
   @media (max-width: 380px) {
       .nav-link {
           padding: 6px 6px;
           font-size: 0.65rem;
       }
   
       .lang-toggle {
           min-width: 42px;
           max-width: 52px;
       }
   
       .lang-label {
           max-width: 26px;
       }
   
       .theme-switch {
           width: 29px;
           height: 29px;
           min-width: 29px;
           min-height: 29px;
       }
   }
   