/**
 * ============================================================
 * Modern Header & Collapsible Sidebar Stylesheet
 * ============================================================
 * Features:
 * - Fixed blurred header bar (`.modern-header`) with CSS backdrop filters
 * - Dynamic sidebar navigation menu (`.modern-sidebar`) with active state highlights
 * - Collapsible mobile drawer support with transition animations
 * - Responsive breakpoints for tablet and mobile viewports
 * - Uses root CSS custom variables derived from custom_style.css
 * ============================================================
 */

/* ---------- Header ---------- */
.modern-header {
    background: var(--bg-header) !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-light) !important;
    height: 72px;
    display: flex;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 1000;
    transition: all 0.3s var(--ease);
}

.modern-header.scrolled {
    box-shadow: var(--shadow-sm);
}

.header-container {
    width: 100%;
    padding: 0 var(--space-4);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

@media (min-width: 1024px) {
    .header-container {
        padding: 0 var(--space-5);
    }
}

.header-logo-link {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none !important;
}

.header-logo-icon {
    font-size: 24px;
    color: var(--primary);
    transition: display 0.2s var(--ease);
}

.header-logo-text {
    font-size: clamp(1rem, 4.5vw, 1.25rem); /* Guideline 18 clamp scaling */
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.6px;
    white-space: nowrap;
}

@media (max-width: 479px) {
    .header-logo-icon {
        display: none !important; /* Hide icon on tiny viewports to free up horizontal space */
    }
    
    .header-logo-text {
        font-size: 0.95rem !important; /* Compact size to fit perfectly on one line */
        max-width: 140px;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .header-actions .header-action-btn:nth-of-type(2) {
        display: none !important; /* Hide secondary help icon to prevent squishing */
    }
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    color: var(--text-secondary) !important;
    text-decoration: none !important;
    transition: all 0.2s var(--ease);
    background: transparent;
}

.header-action-btn:hover {
    background: var(--primary-subtle);
    color: var(--primary) !important;
}

.header-user {
    position: relative;
    margin-left: 12px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    color: var(--text-on-primary);
    font-weight: 700;
    font-size: 15px;
    box-shadow: var(--shadow-xs);
}

.user-info {
    margin-left: 12px;
}

.user-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.user-role {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

.user-dropdown-icon {
    margin-left: 8px;
    font-size: 14px;
    color: var(--text-muted);
}

.header-dropdown-menu {
    min-width: 220px;
    border: 1px solid var(--border-light) !important;
    border-radius: var(--radius-md) !important;
    box-shadow: var(--shadow-lg) !important;
    padding: 8px !important;
    margin-top: 10px !important;
    background: var(--bg-card) !important;
    z-index: 1050 !important;
}

.header-dropdown-menu .dropdown-item {
    border-radius: var(--radius-sm);
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.15s var(--ease);
}

.header-dropdown-menu .dropdown-item:hover {
    background: var(--primary-subtle) !important;
    color: var(--primary) !important;
}

.header-dropdown-menu .dropdown-divider {
    border-color: var(--border-light);
    margin: 6px 0;
}

.mobile-menu-toggle {
    display: block; /* Guideline 1 Mobile First: show by default on mobile */
    background: transparent;
    border: none;
    font-size: 24px;
    color: var(--text-primary);
    cursor: pointer;
    padding: 8px;
    margin-right: 12px;
    border-radius: var(--radius-sm);
    min-height: 44px; /* Guideline 12 button tap target */
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.mobile-menu-toggle:hover {
    background: var(--bg-hover);
}

/* ---------- Sidebar ---------- */
.modern-sidebar,
.pcoded-navbar[navbar-theme="theme1"],
.pcoded-navbar[navbar-theme="themelight1"] {
    width: 280px !important;
    background: var(--bg-sidebar) !important;
    border-right: 1px solid var(--border-light) !important;
    padding-top: 16px;
    height: calc(100vh - 72px);
    position: fixed;
    left: 0;
    top: 72px;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 999;
    transition: transform 0.3s var(--ease);
    transform: translateX(-100%); /* Guideline 17 drawer offcanvas first */
    box-shadow: none;
}

.modern-sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-xl);
}

.modern-sidebar::-webkit-scrollbar { width: 4px; }
.modern-sidebar::-webkit-scrollbar-thumb { background: var(--border-light); }

.nav-section {
    padding: 8px 20px 4px;
}

.nav-section-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1.4px;
    color: var(--text-muted);
    font-weight: 800;
    padding: 16px 12px 8px;
}

.sidebar-nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    margin: 4px 16px;
    border-radius: var(--radius-md);
    color: var(--text-secondary) !important;
    font-weight: 600;
    font-size: 14px;
    text-decoration: none !important;
    transition: all 0.2s var(--ease);
    position: relative;
}

.sidebar-nav-link:hover {
    background: var(--primary-subtle) !important;
    color: var(--primary) !important;
}

.sidebar-nav-link i {
    font-size: 18px;
    color: var(--text-muted);
    width: 24px;
    text-align: center;
    transition: color 0.2s var(--ease);
}

.sidebar-nav-link:hover i {
    color: var(--primary) !important;
}

.sidebar-nav-link.active {
    background: var(--primary-light) !important;
    color: var(--primary) !important;
    font-weight: 700;
}

.sidebar-nav-link.active i {
    color: var(--primary) !important;
}

.sidebar-nav-link.active::after {
    content: '';
    position: absolute;
    right: 0;
    top: 20%;
    bottom: 20%;
    width: 4px;
    background: var(--primary);
    border-radius: 4px 0 0 4px;
}

/* Submenu */
.nav-submenu {
    display: none;
    padding: 4px 0 8px 28px;
}

.nav-item.open .nav-submenu,
.nav-submenu.open {
    display: block;
}

.nav-arrow {
    margin-left: auto;
    font-size: 14px;
    transition: transform 0.2s var(--ease);
}

.sidebar-nav-link.has-submenu.open .nav-arrow {
    transform: rotate(180deg);
}

.submenu-item {
    display: block;
    padding: 10px 16px 10px 32px;
    margin: 2px 16px 2px 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary) !important;
    text-decoration: none !important;
    border-radius: var(--radius-sm);
    transition: all 0.15s var(--ease);
    position: relative;
}

.submenu-item::before {
    content: '';
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: all 0.15s var(--ease);
}

.submenu-item:hover,
.submenu-item.active {
    color: var(--primary) !important;
    background: var(--primary-subtle);
}

.submenu-item:hover::before,
.submenu-item.active::before {
    background: var(--primary);
    transform: translateY(-50%) scale(1.2);
}

/* ---------- Mobile-First Breakpoints (Guideline 2 & 17) ---------- */
.pcoded-content {
    margin-left: 0 !important;
    transition: margin-left 0.3s var(--ease);
}

/* Tablet (min-width: 768px) */
@media (min-width: 768px) {
    /* Responsive Spacing & Typography */
}

/* Laptop (min-width: 1024px) */
@media (min-width: 1024px) {
    .mobile-menu-toggle {
        display: none !important;
    }

    .modern-sidebar {
        transform: translateX(0) !important;
        box-shadow: none !important;
    }

    .pcoded-content {
        margin-left: 280px !important;
    }
}

/* Desktop (min-width: 1280px) */
@media (min-width: 1280px) {
}

/* Large Desktop (min-width: 1536px) */
@media (min-width: 1536px) {
}

/* Custom Dropdown Overrides for Premium Theme Unity */
.header-dropdown-menu .dropdown-item.active {
    background: var(--primary-subtle) !important;
    color: var(--primary) !important;
}

.header-dropdown-menu .dropdown-item.active:hover {
    background: var(--primary-subtle) !important;
    color: var(--primary) !important;
}

.header-dropdown-menu .dropdown-item.active i {
    color: var(--primary) !important;
}
