/**
 * Site header — uses design tokens from theme.css
 */

/* ── Layout (RTL-safe) ─────────────────────────────────── */
.header.-type-4 .header__container .row {
    width: 100%;
}

.header-left {
    display: flex;
    align-items: center;
    min-width: 0;
}

.header-right {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.eman-header__logo {
    padding-inline-end: 30px;
    flex-shrink: 0;
}

.eman-header__nav {
    padding-inline-start: 30px;
    min-width: 0;
}

@media (max-width: 1399px) {
    .eman-header__logo { padding-inline-end: 20px; }
    .eman-header__nav { padding-inline-start: 20px; }
}

@media (max-width: 1199px) {
    .eman-header__logo { padding-inline-end: 0; }
    .eman-header__nav { padding-inline-start: 0; }
}

.eman-header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.eman-header-actions .eman-lang-switcher-wrap {
    margin: 0;
    flex-shrink: 0;
}

.header-student-quick-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.eman-header-btn {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 8px;
    white-space: nowrap;
    flex-shrink: 0;
}

.eman-header-btn .lucide-icon {
    margin: 0 !important;
    flex-shrink: 0;
}

.eman-header-btn-login {
    display: inline-flex !important;
    align-items: center;
    gap: 8px;
    padding-inline-start: 20px !important;
    padding-inline-end: 12px !important;
    white-space: nowrap;
}

.eman-header-btn-login .lucide-icon {
    margin: 0 !important;
}

.eman-header-profile {
    flex-shrink: 0;
}

/* Nav links — icon + label spacing */
.header .menu__nav li > a {
    gap: 8px;
}

/* Nav icons use flex gap — no extra physical margins */
.header .menu__nav li > a .lucide-icon {
    margin: 0 !important;
}

.header a .lucide-icon,
.header button .lucide-icon,
.header-menu a .lucide-icon {
    margin-inline-end: 10px !important;
    margin-bottom: 3px;
}

.header .menu__nav .lucide-icon {
    width: 18px;
    height: 18px;
    stroke-width: 2;
    transition: color var(--transition-fast);
}

.header .menu__nav li > a {
    position: relative;
    display: inline-flex;
    align-items: center;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    transition: color var(--transition-fast), background-color var(--transition-fast);
}

.header .menu__nav li.is-active > a {
    color: var(--eman-purple) !important;
    background-color: rgba(106, 27, 154, 0.08);
    font-weight: var(--font-weight-semibold);
}

.header .menu__nav li.is-active > a::after {
    content: '';
    position: absolute;
    bottom: 4px;
    inset-inline-start: 14px;
    inset-inline-end: 14px;
    height: 2px;
    background: var(--eman-purple);
    border-radius: 1px;
}

.header .menu__nav li.is-active > a,
.header .menu__nav li:not(.is-active) > a:hover {
    color: var(--eman-purple) !important;
}

.header .menu__nav li.is-active > a .lucide-icon,
.header .menu__nav li:not(.is-active) > a:hover .lucide-icon {
    color: var(--eman-purple) !important;
    stroke-width: 2.5;
}

.header .button.-purple-1 .lucide-icon { color: #fff; }
.header .button.-purple-3 .lucide-icon { color: var(--eman-purple); }
.header .button.-underline .lucide-icon { color: var(--eman-text-dark); }

.profile-pill {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding-block: 6px;
    padding-inline-start: 6px;
    padding-inline-end: 14px;
    background-color: #f9f9f9;
    border-radius: var(--radius-pill);
    border: 1px solid #f0f0f0;
    transition: all var(--transition-fast);
    cursor: pointer;
    margin-inline-start: 0;
    position: relative;
    user-select: none;
    font: inherit;
    color: inherit;
    max-width: 200px;
}

button.profile-pill {
    appearance: none;
    -webkit-appearance: none;
}

@media (max-width: 991px) {
    .profile-pill {
        padding: 4px;
        margin-inline-start: var(--space-1);
    }

    .profile-pill img {
        width: 32px;
        height: 32px;
    }
}

@media (max-width: 1399px) {
    .header-student-quick-actions {
        display: none !important;
    }
}

body.eman-mobile-nav-open {
    overflow: hidden;
}

html[dir="rtl"] .header .header-menu {
    left: auto;
    right: 0;
}

html[dir="rtl"] .header .header-menu .header-menu__content {
    transform: translateX(20%);
}

html[dir="rtl"] .header .header-menu.-is-el-visible .header-menu__content {
    transform: none;
}

@media (min-width: 768px) {
    .profile-pill:hover,
    .profile-pill.active {
        background-color: #f0f0f0;
        border-color: var(--eman-purple-light);
    }
}

.profile-pill img {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    object-fit: cover;
}

@media (min-width: 768px) {
    .profile-pill img { width: 38px; height: 38px; }
}

.profile-pill .info {
    display: none;
    text-align: start;
    min-width: 0;
    overflow: hidden;
}

.profile-pill .name {
    font-size: 14px;
    font-weight: var(--font-weight-semibold);
    color: var(--eman-text-dark);
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.profile-pill .role {
    font-size: 11px;
    color: #777;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.profile-pill .chevron-icon {
    flex-shrink: 0;
    margin: 0 !important;
}

@media (min-width: 992px) {
    .profile-pill .info { display: block; }
    .profile-pill .chevron-icon { display: block; }
}

.custom-profile-menu {
    display: none;
    position: absolute;
    top: 120%;
    inset-inline-end: 0;
    width: 240px;
    background-color: var(--eman-bg);
    border: 1px solid #f0f0f0;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-elevated);
    padding: var(--space-2);
    z-index: 9999;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity var(--transition-fast), transform var(--transition-fast);
}

.custom-profile-menu.show {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

@media (max-width: 768px) {
    .custom-profile-menu {
        position: fixed;
        top: 80px;
        inset-inline-end: 15px;
        width: auto;
        max-width: 300px;
    }
}

.custom-menu-header {
    padding: var(--space-2) var(--space-3) var(--space-3);
    border-bottom: 1px solid #f0f0f0;
    margin-bottom: var(--space-1);
}

.custom-menu-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    color: #555;
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: var(--font-weight-medium);
    transition: background-color var(--transition-fast), color var(--transition-fast);
}

.custom-menu-item:hover {
    background-color: #f5f7fa;
    color: var(--eman-purple);
}

.custom-menu-item:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

.custom-menu-item.logout {
    color: #ff4757;
    margin-top: var(--space-1);
    border-top: 1px solid #f0f0f0;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}

.custom-menu-item.logout:hover { background-color: #fff0f1; }

@media (max-width: 1199px) {
    .header-menu__content a {
        display: flex !important;
        align-items: center !important;
        padding: var(--space-2) 0;
    }

    .mobile-user-links {
        display: flex;
        flex-direction: column;
        gap: var(--space-1);
        width: 100%;
        padding-bottom: var(--space-2) !important;
    }

    .mobile-user-links a {
        width: 100%;
        margin-inline-start: 0 !important;
        padding: var(--space-3) 0;
        border-bottom: 1px dashed #eee;
    }

    .mobile-user-links a:last-child { border-bottom: none; }
}

.header.-type-4.-shadow {
    box-shadow: var(--shadow-header);
}

/* Dark mode — keep original light header colors on public pages unless html.-dark-mode */
html.-dark-mode .header.-type-4.bg-white {
    background-color: #1a2230 !important;
    border-bottom-color: #2a303b !important;
}

html.-dark-mode .header .menu__nav li > a {
    color: rgba(255, 255, 255, 0.85) !important;
}

html.-dark-mode .profile-pill {
    background-color: #0a0f1a;
    border-color: #333;
}

html.-dark-mode .profile-pill .name {
    color: #fff;
}

html.-dark-mode .custom-profile-menu {
    background-color: #1a2230;
    border-color: #2a303b;
}

html.-dark-mode .custom-menu-header {
    border-bottom-color: #2a303b;
}

html.-dark-mode .custom-menu-item {
    color: rgba(255, 255, 255, 0.8);
}

html.-dark-mode .custom-menu-item:hover {
    background-color: #0a0f1a;
    color: var(--eman-purple-light);
}

/* RTL: decorative borders use logical side */
html[dir="rtl"] .header.-type-4 *.-before-border::before,
html[dir="ltr"] .header.-type-4 *.-before-border::before {
    left: auto;
    inset-inline-start: 0;
}

html[dir="rtl"] .header.-type-4 *.-after-border::after,
html[dir="ltr"] .header.-type-4 *.-after-border::after {
    right: auto;
    inset-inline-end: 0;
}

/* Tighter actions on medium-wide Arabic screens */
@media (min-width: 1200px) and (max-width: 1499px) {
    .header-student-quick-actions .eman-header-btn {
        padding-inline: 18px !important;
        font-size: 14px;
    }

    .profile-pill {
        max-width: 160px;
    }
}
