/**
 * Apex eCampus - Modern Header Styles
 * Clean, professional navbar with blue accent
 */

/* ============================================
   CSS VARIABLES
   ============================================ */
:root {
    --header-height: 64px;
    --header-bg: #ffffff;
    --header-border: #e5e7eb;
    --header-text: #1f2937;
    --header-text-muted: #6b7280;
    --header-primary: #2563eb;
    --header-primary-light: #3b82f6;
    --header-primary-dark: #1d4ed8;
    --header-hover-bg: #f3f4f6;
    --header-shadow: 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* ============================================
   MAIN HEADER STYLES
   ============================================ */
.apex-header {
    height: var(--header-height);
    background: var(--header-bg);
    border-bottom: 1px solid var(--header-border);
    box-shadow: var(--header-shadow);
    padding: 0 !important;
    z-index: 1030;
}

.apex-header__container {
    display: flex;
    align-items: center;
    height: 100%;
    max-width: 100%;
    padding: 0 1.5rem;
    gap: 1rem;
}

/* ============================================
   MOBILE TOGGLE
   ============================================ */
.apex-header__toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--header-text);
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.apex-header__toggle:hover {
    background: var(--header-hover-bg);
    color: var(--header-primary);
}

/* ============================================
   BRAND / LOGO
   ============================================ */
.apex-header__brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    flex-shrink: 0;
    padding: 0.5rem;
    border-radius: 10px;
    transition: all 0.2s ease;
}

.apex-header__brand:hover {
    background: var(--header-hover-bg);
}

.apex-header__logo {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    object-fit: cover;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease;
}

.apex-header__brand:hover .apex-header__logo {
    transform: scale(1.05);
}

.apex-header__sitename {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--header-text);
    letter-spacing: -0.025em;
    background: linear-gradient(135deg, var(--header-primary) 0%, var(--header-primary-dark) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ============================================
   PRIMARY NAVIGATION
   ============================================ */
.apex-header__nav {
    display: flex;
    align-items: center;
    margin-left: 1rem;
}

.apex-header__nav .moremenu {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.apex-header__nav .nav-link {
    display: flex;
    align-items: center;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--header-text-muted);
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.apex-header__nav .nav-link:hover {
    color: var(--header-primary);
    background: rgba(37, 99, 235, 0.08);
}

.apex-header__nav .nav-link.active {
    color: var(--header-primary);
    background: rgba(37, 99, 235, 0.1);
    font-weight: 600;
}

/* More menu dropdown */
.apex-header__nav .dropdown-toggle::after {
    margin-left: 0.5rem;
    opacity: 0.5;
}

.apex-header__nav .dropdown-menu {
    border: 1px solid var(--header-border);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    padding: 0.5rem;
    margin-top: 0.5rem;
}

.apex-header__nav .dropdown-item {
    padding: 0.625rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    color: var(--header-text);
    transition: all 0.15s ease;
}

.apex-header__nav .dropdown-item:hover {
    background: rgba(37, 99, 235, 0.08);
    color: var(--header-primary);
}

/* ============================================
   RIGHT SIDE ACTIONS
   ============================================ */
.apex-header__actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
}

/* Search Box */
.apex-header__search {
    position: relative;
}

.apex-header__search .form-control,
.apex-header__search input[type="text"] {
    height: 38px;
    padding: 0.5rem 1rem 0.5rem 2.5rem;
    font-size: 0.875rem;
    background: var(--header-hover-bg);
    border: 1px solid transparent;
    border-radius: 20px;
    min-width: 200px;
    transition: all 0.2s ease;
}

.apex-header__search .form-control:focus,
.apex-header__search input[type="text"]:focus {
    background: #ffffff;
    border-color: var(--header-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
    outline: none;
}

.apex-header__search .search-icon,
.apex-header__search .icon {
    position: absolute;
    left: 0.875rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--header-text-muted);
    pointer-events: none;
}

/* Language Menu */
.apex-header__lang {
    display: flex;
    align-items: center;
}

.apex-header__lang .dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
    color: var(--header-text-muted);
    background: transparent;
    border: none;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.apex-header__lang .dropdown-toggle:hover {
    background: var(--header-hover-bg);
    color: var(--header-text);
}

/* Notifications Area */
.apex-header__notifications {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.apex-header__notifications .popover-region {
    margin: 0;
}

.apex-header__notifications .popover-region-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    border-radius: 10px;
    color: var(--header-text-muted);
    transition: all 0.2s ease;
    position: relative;
}

.apex-header__notifications .popover-region-toggle:hover {
    background: var(--header-hover-bg);
    color: var(--header-primary);
}

.apex-header__notifications .popover-region-toggle .icon {
    width: 20px;
    height: 20px;
}

/* Notification Badge */
.apex-header__notifications .count-container {
    position: absolute;
    top: 4px;
    right: 4px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    font-size: 0.7rem;
    font-weight: 600;
    color: #ffffff;
    background: #ef4444;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ============================================
   USER MENU
   ============================================ */
.apex-header__user {
    display: flex;
    align-items: center;
}

.apex-header__user .usermenu {
    display: flex;
    align-items: center;
}

.apex-header__user .dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.375rem 0.75rem 0.375rem 0.375rem;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 50px;
    transition: all 0.2s ease;
    text-decoration: none;
}

.apex-header__user .dropdown-toggle:hover {
    background: var(--header-hover-bg);
    border-color: var(--header-border);
}

.apex-header__user .userpicture {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--header-border);
    transition: border-color 0.2s ease;
}

.apex-header__user .dropdown-toggle:hover .userpicture {
    border-color: var(--header-primary-light);
}

.apex-header__user .usertext {
    display: none;
}

@media (min-width: 992px) {
    .apex-header__user .usertext {
        display: block;
        font-size: 0.875rem;
        font-weight: 500;
        color: var(--header-text);
        max-width: 120px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

/* User Dropdown Menu */
.apex-header__user .dropdown-menu {
    min-width: 240px;
    border: 1px solid var(--header-border);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12);
    padding: 0.5rem;
    margin-top: 0.5rem;
}

.apex-header__user .dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    color: var(--header-text);
    transition: all 0.15s ease;
}

.apex-header__user .dropdown-item:hover {
    background: rgba(37, 99, 235, 0.08);
    color: var(--header-primary);
}

.apex-header__user .dropdown-item .icon {
    width: 18px;
    height: 18px;
    opacity: 0.7;
}

.apex-header__user .dropdown-divider {
    margin: 0.5rem 0;
    border-color: var(--header-border);
}

/* Carousel (user details in dropdown) */
.apex-header__user .carousel-item.active {
    display: flex;
    flex-direction: column;
}

.apex-header__user .carousel-navigation-link {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    color: var(--header-primary);
}

/* ============================================
   EDIT SWITCH
   ============================================ */
.apex-header .editmode-switch-form {
    margin-left: 0.5rem;
}

.apex-header .editmode-switch-form .custom-control-label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--header-text-muted);
}

.apex-header .editmode-switch-form .custom-switch .custom-control-input:checked ~ .custom-control-label::before {
    background-color: var(--header-primary);
    border-color: var(--header-primary);
}

/* ============================================
   RESPONSIVE ADJUSTMENTS
   ============================================ */

/* Tablet */
@media (max-width: 991px) {
    .apex-header__container {
        padding: 0 1rem;
        gap: 0.75rem;
    }

    .apex-header__search .form-control,
    .apex-header__search input[type="text"] {
        min-width: 160px;
    }

    .apex-header__nav .nav-link {
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
    }
}

/* Mobile */
@media (max-width: 767px) {
    :root {
        --header-height: 56px;
    }

    .apex-header__container {
        padding: 0 0.75rem;
        gap: 0.5rem;
    }

    .apex-header__logo {
        width: 36px;
        height: 36px;
        border-radius: 8px;
    }

    .apex-header__toggle {
        width: 36px;
        height: 36px;
    }

    .apex-header__search {
        display: none;
    }

    .apex-header__lang {
        display: none;
    }

    .apex-header__notifications .popover-region-toggle {
        width: 36px;
        height: 36px;
    }

    .apex-header__user .dropdown-toggle {
        padding: 0.25rem;
    }

    .apex-header__user .userpicture {
        width: 32px;
        height: 32px;
    }
}

/* Small Mobile */
@media (max-width: 480px) {
    .apex-header__brand {
        padding: 0.25rem;
    }

    .apex-header__notifications .count-container {
        min-width: 16px;
        height: 16px;
        font-size: 0.65rem;
    }
}

/* ============================================
   PAGE CONTENT OFFSET
   ============================================ */
#page {
    padding-top: var(--header-height) !important;
    margin-top: 0 !important;
}

/* Fix for course index drawer position */
.drawer {
    top: var(--header-height);
    height: calc(100vh - var(--header-height));
}

/* ============================================
   DROPDOWNS GLOBAL STYLES
   ============================================ */
.apex-header .dropdown-menu {
    animation: dropdownFadeIn 0.15s ease;
}

@keyframes dropdownFadeIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */
.apex-header__toggle:focus-visible,
.apex-header__brand:focus-visible,
.apex-header__nav .nav-link:focus-visible,
.apex-header__notifications .popover-region-toggle:focus-visible,
.apex-header__user .dropdown-toggle:focus-visible {
    outline: 2px solid var(--header-primary);
    outline-offset: 2px;
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
    .apex-header {
        display: none !important;
    }
}
