/* Global Header Styles Extracted from patient_area_v2.css */
:root {
    --header-bg0: #060913;
    --header-stroke: rgba(255, 255, 255, .08);
    --header-text: #E9EEFF;
    --header-muted: rgba(233, 238, 255, .72);
    --header-aqua: #50B6FF;
    --header-turq: #2DCCCD;
    --header-maxw: 1120px;
    --header-font: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
}

/* Base resets for header elements to avoid inheriting page styles */
.topbar *:not(i) {
    box-sizing: border-box;
    font-family: var(--header-font);
}

.lucide {
    width: 20px;
    height: 20px;
    stroke-width: 2px;
}

.navPill .lucide {
    width: 16px;
    height: 16px;
    stroke-width: 2.5px;
}

.topbar .lucide,
.topbar i {
    /* Normalize FontAwesome and Lucide */
    display: inline-block;
    vertical-align: middle;
}

.topbar i {
    font-family: 'Font Awesome 6 Free', 'FontAwesome', sans-serif;
    /* Ensure fallback */
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 1000;
    /* Higher Z-index for safety */
    padding: 12px 0 10px;
    -webkit-backdrop-filter: blur(22px);
    backdrop-filter: blur(22px);
    background: linear-gradient(180deg, rgba(6, 9, 19, .86), rgba(6, 9, 19, .46));
    border-bottom: 1px solid rgba(255, 255, 255, .06);
}

body.light-theme .topbar {
    background: linear-gradient(180deg, #103563, #091E3A) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
    color: #E9EEFF !important;
}

body.light-theme .navPill {
    color: rgba(233, 238, 255, 0.8);
}

body.light-theme .navPill:hover,
body.light-theme .navPill.active {
    color: #FFFFFF;
    background: rgba(255, 255, 255, 0.1);
}

body.light-theme .btn {
    border-color: rgba(0, 0, 0, 0.1);
    color: #0f172a !important;
    background: rgba(255, 255, 255, 0.6);
}

body.light-theme .topbar i,
body.light-theme .topbar .lucide {
    color: #E2E8F0 !important;
}

.topbar .wrap {
    max-width: var(--header-maxw);
    margin: 0 auto;
    padding: 0 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 170px
}

.navPills {
    display: none;
    gap: 8px;
    align-items: center;
    justify-content: center;
    padding: 6px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, .07);
    background: rgba(0, 0, 0, .14);
}

body.light-theme .navPills {
    background: rgba(0, 0, 0, 0.2) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
}

@media (min-width: 860px) {
    .navPills {
        display: flex;
    }
}

.navPill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 999px;
    font-size: 12px;
    color: var(--header-muted);
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    background: transparent;
}

.navPill:hover {
    color: var(--header-text);
    background: rgba(255, 255, 255, 0.05);
}

.navPill.active {
    color: var(--header-text);
    background: linear-gradient(135deg, rgba(80, 182, 255, .30), rgba(45, 204, 205, .16));
    border-color: rgba(80, 182, 255, .25);
}

.rightPills {
    display: flex;
    gap: 10px;
    align-items: center
}

/* Buttons inside header */
.topbar .btn {
    height: 36px;
    padding: 0 14px;
    border-radius: 12px;
    border: 1px solid var(--header-stroke);
    background: rgba(255, 255, 255, .06);
    color: var(--header-text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-weight: 650;
    letter-spacing: .15px;
    cursor: pointer;
    user-select: none;
    text-decoration: none;
    font-size: 13px;
}

.topbar .btn:hover {
    background: rgba(255, 255, 255, .1);
}

.topbar .btn.primary {
    /* If needed */
    background: linear-gradient(135deg, rgba(80, 182, 255, .28), rgba(45, 204, 205, .16));
    border-color: rgba(80, 182, 255, .45);
}

.topbar .btn-mini {
    height: 32px;
    padding: 0 12px;
    border-radius: 999px;
    border: 1px solid var(--header-stroke);
    background: rgba(255, 255, 255, .05);
    color: var(--header-text);
    font-size: 11px;
    font-weight: 600;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, .10);
    background: rgba(80, 182, 255, .12);
    display: grid;
    place-items: center;
    font-weight: 750;
    cursor: pointer;
    /* overflow: hidden; Removed to allow dropdown menu to show */
    color: #fff;
}

.avatar-menu {
    border: 1px solid #334;
}

/* --- Mobile Menu Styles --- */
.hamburger-btn {
    display: none;
}

@media (max-width: 860px) {
    .hamburger-btn {
        display: inline-flex !important;
    }

    .navPills {
        display: none !important;
    }
}

@media (max-width: 600px) {
    .btn-text {
        display: none;
    }
}

/* Overlay */
.mobile-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 2000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mobile-menu-overlay.open {
    opacity: 1;
}

/* Drawer */
.mobile-menu-drawer {
    position: fixed;
    top: 0;
    right: -100%;
    width: 85%;
    max-width: 320px;
    height: 100vh;
    background: #0f172a;
    z-index: 2001;
    transition: right 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
}

.mobile-menu-drawer.open {
    right: 0;
}

.mobile-menu-header {
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.close-menu-btn {
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
}

.mobile-menu-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mobile-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 12px;
    color: #cbd5e1;
    text-decoration: none;
    font-size: 15px;
    font-weight: 500;
    background: transparent;
    border: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s;
}

.mobile-nav-item i,
.mobile-nav-item .lucide {
    width: 24px;
    text-align: center;
    opacity: 0.7;
}

.mobile-nav-item:hover,
.mobile-nav-item:active {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
}

.mobile-nav-item.highlight {
    background: rgba(80, 182, 255, 0.1);
    color: #50b6ff;
}

.mobile-nav-item.logout {
    color: #f87171;
}

.mobile-nav-item.logout:hover {
    background: rgba(248, 113, 113, 0.1);
}

.mobile-menu-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.05);
    margin: 8px 0;
}

/* --- RTL Support --- */
[dir="rtl"] .lang-switcher {
    margin-right: 0 !important;
    margin-left: 12px !important;
}

[dir="rtl"] .lang-menu,
[dir="rtl"] .avatar-menu {
    right: auto !important;
    left: 0 !important;
}

[dir="rtl"] .mobile-menu-drawer {
    right: auto;
    left: -100%;
    border-left: none;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.5);
}

[dir="rtl"] .mobile-menu-drawer.open {
    right: auto;
    left: 0;
}

[dir="rtl"] .navPill {
    font-size: 13px;
    /* Slightly larger for Arabic legibility */
}

[dir="rtl"] .mobile-nav-item {
    text-align: right;
}

/* MOBILE HEADER ADJUSTMENTS */
@media (max-width: 768px) {

    /* Prevent body scroll from header overflow */
    body {
        overflow-x: hidden;
        width: 100%;
        position: relative;
    }

    .topbar .wrap {
        padding: 0 4px;
        /* Minimal padding */
        gap: 2px;
        width: 100%;
        max-width: 100vw;
        box-sizing: border-box;
    }

    .brand {
        min-width: 0;
        gap: 4px;
        flex: 1;
        overflow: hidden;
    }

    .brandName {
        font-size: 15px;
        letter-spacing: 0;
        line-height: 1;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .logoMark {
        width: 26px;
        height: 26px;
        flex-shrink: 0;
    }

    .rightPills {
        gap: 1px;
        flex-shrink: 0;
    }

    .lang-switcher {
        margin-right: -4px;
        margin-left: -4px;
        transform: scale(0.8);
    }

    .menu-toggle {
        padding: 4px;
        margin-right: -4px;
    }

    /* Generic button compaction for header */
    .topbar .btn-icon,
    .theme-toggle,
    .avatar-menu-toggle {
        width: 28px;
        height: 28px;
        padding: 0;
        display: grid;
        place-items: center;
    }

}

@media (max-width: 860px) {
    .desktop-only {
        display: none !important;
    }
}