html,
body {
    overflow-x: hidden;
}

/* Navbar container */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 8px 12px;
    background: linear-gradient(135deg, #2151e0, #1d4ed8 55%, #1a3fc0);
    padding: 12px 22px;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 4px 16px rgba(15, 32, 89, 0.18);
}

/* Navbar links */
.navbar a {
    color: white;
    text-decoration: none;
    margin: 0;
    font-weight: 500;
    padding: 6px 10px;
    border-radius: 999px;
    transition: background-color 0.2s ease, transform 0.15s ease;
}

.navbar a:hover {
    text-decoration: none;
    background-color: rgba(255, 255, 255, 0.14);
    transform: translateY(-1px);
}

.navbar-left,
.navbar-right {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 14px;
}

.navbar-left {
    flex: 1 1 auto;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
}

.navbar-right {
    flex: 0 0 auto;
    justify-content: flex-end;
    margin-left: auto;
}

.nav-profile {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    padding: 4px 10px 4px 4px;
    border-radius: 999px;
    transition: background-color 0.2s ease;
}

.nav-profile:hover {
    background-color: rgba(255, 255, 255, 0.14);
}

.nav-profile img {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.55);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.nav-profile span {
    max-width: 16ch;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-profile.is-large img {
    width: 32px;
    height: 32px;
}

.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #ffffff;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.15s ease;
}

.theme-toggle:hover {
    background-color: rgba(255, 255, 255, 0.14);
    transform: scale(1.06);
}

.theme-toggle:active {
    transform: scale(0.94);
}

.theme-icon-moon {
    display: none;
}

.theme-icon {
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.theme-toggle.is-spinning .theme-icon {
    transform: rotate(180deg) scale(1.15);
}

[data-theme="dark"] .theme-icon-sun {
    display: none;
}

[data-theme="dark"] .theme-icon-moon {
    display: inline;
}

@media (max-width: 768px) {
    .navbar {
        padding: 10px 12px;
        justify-content: space-between;
        flex-wrap: nowrap;
    }

    .navbar-left,
    .navbar-right {
        width: auto;
        justify-content: flex-start;
    }

    .navbar-left {
        align-items: flex-start;
    }

    .navbar-right {
        margin-left: auto;
    }

    .navbar a {
        font-size: 13px;
    }

    .nav-profile img {
        width: 24px;
        height: 24px;
    }
}

html[dir="rtl"] body {
    direction: rtl;
}

/* The navbar keeps the same layout in Arabic as in English: links on the
   left, theme toggle + profile on the right. Arabic text inside still
   renders right-to-left on its own. */
html[dir="rtl"] .navbar,
html[dir="rtl"] .navbar-left,
html[dir="rtl"] .navbar-right {
    direction: ltr !important;
}

html[dir="rtl"] .navbar-left {
    margin: 0 !important;
    align-items: flex-start !important;
    text-align: left !important;
}

html[dir="rtl"] .navbar-right {
    margin-left: auto !important;
    margin-right: 0 !important;
    justify-content: flex-end !important;
}
