/**
 * HygieneTech Modern Header v1.0
 * Clean, compact, mobile-first design
 * All classes prefixed: ht-header-*
 */

/* ===========================================
   CSS VARIABLES
   =========================================== */
:root {
    --ht-header-height: 60px;
    --ht-header-bg: #ffffff;
    --ht-header-bg-dark: #1e293b;
    --ht-header-border: #e2e8f0;
    --ht-header-border-dark: #334155;
    --ht-header-text: #334155;
    --ht-header-text-muted: #64748b;
    --ht-header-text-dark: #e2e8f0;
    --ht-header-text-muted-dark: #94a3b8;
    --ht-header-accent: #6366f1;
    --ht-header-accent-hover: #4f46e5;
    --ht-header-hover-bg: #f1f5f9;
    --ht-header-hover-bg-dark: #334155;
    --ht-header-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    --ht-header-shadow-dark: 0 1px 3px rgba(0, 0, 0, 0.2);
    --ht-header-dropdown-shadow: 0 10px 40px rgba(0, 0, 0, 0.12);
    --ht-header-dropdown-shadow-dark: 0 10px 40px rgba(0, 0, 0, 0.4);
    --ht-header-radius: 8px;
    --ht-header-transition: 0.2s ease;
    
    /* Color tokens */
    --ht-color-success: #22c55e;
    --ht-color-warning: #f59e0b;
    --ht-color-danger: #ef4444;
    --ht-color-info: #3b82f6;
    --ht-color-primary: #6366f1;
}

/* ===========================================
   HEADER BASE
   =========================================== */
.ht-header {
    position: fixed;
    top: 0;
    left: var(--ht-sidebar-width, 250px);
    right: 0;
    height: var(--ht-header-height);
    background: var(--ht-header-bg);
    border-bottom: 1px solid var(--ht-header-border);
    box-shadow: var(--ht-header-shadow);
    z-index: 100;
    transition: left var(--ht-header-transition), right var(--ht-header-transition), background var(--ht-header-transition);
}

[dir="rtl"] .ht-header {
    left: 0;
    right: var(--ht-sidebar-width, 250px);
}

/* Dark mode */
.dark-only .ht-header,
body.dark-only .ht-header {
    background: var(--ht-header-bg-dark);
    border-color: var(--ht-header-border-dark);
    box-shadow: var(--ht-header-shadow-dark);
}

/* Collapsed sidebar */
.close_icon .ht-header,
.page-wrapper.close_icon .ht-header {
    left: var(--ht-sidebar-collapsed-width, 80px);
}

[dir="rtl"] .close_icon .ht-header,
[dir="rtl"] .page-wrapper.close_icon .ht-header {
    left: 0;
    right: var(--ht-sidebar-collapsed-width, 80px);
}

/* ===========================================
   HEADER INNER CONTAINER
   =========================================== */
.ht-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    padding: 0 20px;
    gap: 16px;
}

/* ===========================================
   HEADER START (Left Side)
   =========================================== */
.ht-header-start {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

/* Hamburger Toggle */
.ht-header-toggle {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 36px;
    height: 36px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: var(--ht-header-radius);
    cursor: pointer;
    gap: 5px;
    transition: background var(--ht-header-transition);
}

.ht-header-toggle:hover {
    background: var(--ht-header-hover-bg);
}

.dark-only .ht-header-toggle:hover {
    background: var(--ht-header-hover-bg-dark);
}

.ht-header-toggle-bar {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--ht-header-text);
    border-radius: 2px;
    transition: transform var(--ht-header-transition), opacity var(--ht-header-transition);
}

.dark-only .ht-header-toggle-bar {
    background: var(--ht-header-text-dark);
}

/* Toggle active state */
.ht-header-toggle.active .ht-header-toggle-bar:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.ht-header-toggle.active .ht-header-toggle-bar:nth-child(2) {
    opacity: 0;
}

.ht-header-toggle.active .ht-header-toggle-bar:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

/* Logo */
.ht-header-logo {
    display: none;
}

.ht-header-logo-img {
    height: 32px;
    width: auto;
}

/* ===========================================
   HEADER CENTER (Smart Breadcrumb)
   =========================================== */
.ht-header-center {
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

/* Breadcrumb Nav Container */
.ht-breadcrumb {
    display: flex;
    align-items: center;
    min-width: 0;
    overflow: hidden;
    width: 100%;
}

.ht-breadcrumb-list {
    display: flex;
    align-items: center;
    list-style: none;
    margin: 0;
    padding: 0;
    flex-wrap: nowrap;
    min-width: 0;
    overflow: hidden;
    gap: 2px;
}

/* Individual Breadcrumb Item */
.ht-breadcrumb-item {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    min-width: 0;
    white-space: nowrap;
}

/* Allow the last item to truncate */
.ht-breadcrumb-item.ht-breadcrumb-current {
    flex-shrink: 1;
    min-width: 40px;
    overflow: hidden;
}

/* Separator Chevron */
.ht-breadcrumb-sep {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ht-header-text-muted);
    opacity: 0.5;
    flex-shrink: 0;
    margin: 0 2px;
}

.ht-breadcrumb-sep svg {
    display: block;
}

.dark-only .ht-breadcrumb-sep {
    color: var(--ht-header-text-muted-dark);
}

/* Clickable Ancestor Links */
.ht-breadcrumb-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--ht-header-text-muted);
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    padding: 4px 6px;
    border-radius: 4px;
    transition: color 0.15s ease, background 0.15s ease;
    max-width: 180px;
    min-width: 0;
}

.ht-breadcrumb-link span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.ht-breadcrumb-link:hover {
    color: var(--ht-header-accent);
    background: rgba(99, 102, 241, 0.08);
    text-decoration: none;
}

.ht-breadcrumb-link:active {
    background: rgba(99, 102, 241, 0.14);
}

.dark-only .ht-breadcrumb-link {
    color: var(--ht-header-text-muted-dark);
}

.dark-only .ht-breadcrumb-link:hover {
    color: var(--ht-header-accent);
    background: rgba(99, 102, 241, 0.15);
}

/* Home Icon */
.ht-breadcrumb-home {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    opacity: 0.85;
}

.ht-breadcrumb-link:hover .ht-breadcrumb-home {
    opacity: 1;
}

/* Current Page (last crumb, non-clickable) */
.ht-breadcrumb-text {
    color: var(--ht-header-text);
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 4px 6px;
    max-width: 260px;
}

.dark-only .ht-breadcrumb-text {
    color: var(--ht-header-text-dark);
}

/* Current page crumb gets accent underline dot */
.ht-breadcrumb-current .ht-breadcrumb-text {
    color: var(--ht-header-text);
}

.dark-only .ht-breadcrumb-current .ht-breadcrumb-text {
    color: var(--ht-header-text-dark);
}

/* Legacy fallback styles (when no breadcrumbs data) */
.ht-header-breadcrumb {
    color: var(--ht-header-text-muted);
    font-size: 13px;
    font-weight: 500;
}

.dark-only .ht-header-breadcrumb {
    color: var(--ht-header-text-muted-dark);
}

.ht-header-separator {
    color: var(--ht-header-text-muted);
    font-size: 13px;
}

.dark-only .ht-header-separator {
    color: var(--ht-header-text-muted-dark);
}

.ht-header-title {
    color: var(--ht-header-text);
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dark-only .ht-header-title {
    color: var(--ht-header-text-dark);
}

/* ===========================================
   HEADER END (Right Side Actions)
   =========================================== */
.ht-header-end {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

/* ===========================================
   HEADER ITEMS (Buttons)
   =========================================== */
.ht-header-item {
    position: relative;
}

.ht-header-item > button,
.ht-header-item > a,
.ht-header-dropdown-trigger {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 10px;
    background: transparent;
    border: none;
    border-radius: var(--ht-header-radius);
    color: var(--ht-header-text);
    cursor: pointer;
    transition: background var(--ht-header-transition), color var(--ht-header-transition);
    text-decoration: none;
}

.ht-header-item > button:hover,
.ht-header-item > a:hover,
.ht-header-dropdown-trigger:hover {
    background: var(--ht-header-hover-bg);
}

.dark-only .ht-header-item > button,
.dark-only .ht-header-item > a,
.dark-only .ht-header-dropdown-trigger {
    color: var(--ht-header-text-dark);
}

.dark-only .ht-header-item > button:hover,
.dark-only .ht-header-item > a:hover,
.dark-only .ht-header-dropdown-trigger:hover {
    background: var(--ht-header-hover-bg-dark);
}

/* Icons */
.ht-header-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

/* ===========================================
   LANGUAGE SWITCH
   =========================================== */
.ht-header-lang-btn {
    display: flex;
    align-items: center;
    gap: 6px;
}

.ht-header-lang-label {
    font-size: 13px;
    font-weight: 600;
    min-width: 20px;
    text-align: center;
}

/* ===========================================
   DARK MODE TOGGLE
   =========================================== */
.ht-header-mode {
    overflow: hidden;
}

.ht-header-icon-sun {
    display: none;
}

.ht-header-icon-moon {
    display: block;
}

.dark-only .ht-header-icon-sun {
    display: block;
}

.dark-only .ht-header-icon-moon {
    display: none;
}

/* ===========================================
   NOTIFICATION BADGE
   =========================================== */
.ht-header-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: var(--ht-color-danger);
    color: #ffffff;
    font-size: 10px;
    font-weight: 600;
    line-height: 18px;
    text-align: center;
    border-radius: 9px;
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.3);
}

[dir="rtl"] .ht-header-badge {
    right: auto;
    left: 4px;
}

/* ===========================================
   DROPDOWN MENU BASE
   =========================================== */
.ht-header-dropdown {
    position: relative;
}

.ht-header-dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 280px;
    max-width: 340px;
    background: var(--ht-header-bg);
    border: 1px solid var(--ht-header-border);
    border-radius: 12px;
    box-shadow: var(--ht-header-dropdown-shadow);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: opacity var(--ht-header-transition), transform var(--ht-header-transition), visibility var(--ht-header-transition);
    z-index: 1000;
}

[dir="rtl"] .ht-header-dropdown-menu {
    right: auto;
    left: 0;
}

.dark-only .ht-header-dropdown-menu {
    background: var(--ht-header-bg-dark);
    border-color: var(--ht-header-border-dark);
    box-shadow: var(--ht-header-dropdown-shadow-dark);
}

/* Open state */
.ht-header-dropdown.open .ht-header-dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Dropdown Header */
.ht-header-dropdown-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--ht-header-border);
}

.dark-only .ht-header-dropdown-header {
    border-color: var(--ht-header-border-dark);
}

.ht-header-dropdown-header h4 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--ht-header-text);
}

.dark-only .ht-header-dropdown-header h4 {
    color: var(--ht-header-text-dark);
}

.ht-header-dropdown-count {
    font-size: 12px;
    font-weight: 500;
    color: var(--ht-header-accent);
    background: rgba(99, 102, 241, 0.1);
    padding: 2px 8px;
    border-radius: 10px;
}

/* Dropdown Body */
.ht-header-dropdown-body {
    max-height: 320px;
    overflow-y: auto;
    padding: 8px;
}

.ht-header-dropdown-body::-webkit-scrollbar {
    width: 4px;
}

.ht-header-dropdown-body::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
}

.dark-only .ht-header-dropdown-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
}

/* Dropdown Footer */
.ht-header-dropdown-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--ht-header-border);
    text-align: center;
}

.dark-only .ht-header-dropdown-footer {
    border-color: var(--ht-header-border-dark);
}

.ht-header-dropdown-footer a {
    color: var(--ht-header-accent);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
}

.ht-header-dropdown-footer a:hover {
    color: var(--ht-header-accent-hover);
    text-decoration: underline;
}

/* ===========================================
   NOTIFICATIONS DROPDOWN
   =========================================== */
.ht-header-notifications-menu {
    width: 340px;
}

/* Empty State */
.ht-header-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px 16px;
    text-align: center;
}

.ht-header-empty svg {
    width: 48px;
    height: 48px;
    color: var(--ht-header-text-muted);
    margin-bottom: 12px;
}

.dark-only .ht-header-empty svg {
    color: var(--ht-header-text-muted-dark);
}

.ht-header-empty p {
    margin: 0;
    color: var(--ht-header-text-muted);
    font-size: 14px;
}

.dark-only .ht-header-empty p {
    color: var(--ht-header-text-muted-dark);
}

/* Notification List */
.ht-header-notification-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.ht-header-notification-item {
    margin-bottom: 4px;
}

.ht-header-notification-link {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--ht-header-radius);
    text-decoration: none;
    transition: background var(--ht-header-transition);
}

.ht-header-notification-link:hover {
    background: var(--ht-header-hover-bg);
}

.dark-only .ht-header-notification-link:hover {
    background: var(--ht-header-hover-bg-dark);
}

/* Unread indicator */
.ht-header-notification-unread .ht-header-notification-link {
    background: rgba(99, 102, 241, 0.05);
}

.dark-only .ht-header-notification-unread .ht-header-notification-link {
    background: rgba(99, 102, 241, 0.1);
}

/* Notification Icon */
.ht-header-notification-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    flex-shrink: 0;
}

.ht-header-notification-icon svg {
    width: 18px;
    height: 18px;
}

.ht-header-notification-icon-success {
    background: rgba(34, 197, 94, 0.12);
    color: var(--ht-color-success);
}

.ht-header-notification-icon-warning {
    background: rgba(245, 158, 11, 0.12);
    color: var(--ht-color-warning);
}

.ht-header-notification-icon-danger {
    background: rgba(239, 68, 68, 0.12);
    color: var(--ht-color-danger);
}

.ht-header-notification-icon-info {
    background: rgba(59, 130, 246, 0.12);
    color: var(--ht-color-info);
}

.ht-header-notification-icon-primary {
    background: rgba(99, 102, 241, 0.12);
    color: var(--ht-color-primary);
}

/* Notification Content */
.ht-header-notification-content {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.ht-header-notification-title {
    color: var(--ht-header-text);
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 2px;
}

.dark-only .ht-header-notification-title {
    color: var(--ht-header-text-dark);
}

.ht-header-notification-unread .ht-header-notification-title {
    color: var(--ht-header-accent);
}

.ht-header-notification-text {
    color: var(--ht-header-text-muted);
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.dark-only .ht-header-notification-text {
    color: var(--ht-header-text-muted-dark);
}

.ht-header-notification-time {
    color: var(--ht-header-text-muted);
    font-size: 11px;
}

.dark-only .ht-header-notification-time {
    color: var(--ht-header-text-muted-dark);
}

/* ===========================================
   USER DROPDOWN
   =========================================== */
.ht-header-user-trigger {
    gap: 10px;
    padding: 0 12px !important;
}

.ht-header-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--ht-header-border);
}

.dark-only .ht-header-avatar {
    border-color: var(--ht-header-border-dark);
}

.ht-header-user-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--ht-header-text);
    max-width: 120px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dark-only .ht-header-user-name {
    color: var(--ht-header-text-dark);
}

.ht-header-chevron {
    width: 16px;
    height: 16px;
    color: var(--ht-header-text-muted);
    transition: transform var(--ht-header-transition);
}

.dark-only .ht-header-chevron {
    color: var(--ht-header-text-muted-dark);
}

.ht-header-dropdown.open .ht-header-chevron {
    transform: rotate(180deg);
}

/* User Menu */
.ht-header-user-menu {
    width: 240px;
}

.ht-header-user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    border-bottom: 1px solid var(--ht-header-border);
}

.dark-only .ht-header-user-info {
    border-color: var(--ht-header-border-dark);
}

.ht-header-user-avatar-lg {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
}

.ht-header-user-details {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.ht-header-user-details strong {
    color: var(--ht-header-text);
    font-size: 14px;
    font-weight: 600;
}

.dark-only .ht-header-user-details strong {
    color: var(--ht-header-text-dark);
}

.ht-header-user-details span {
    color: var(--ht-header-text-muted);
    font-size: 12px;
}

.dark-only .ht-header-user-details span {
    color: var(--ht-header-text-muted-dark);
}

/* User Links */
.ht-header-user-links {
    list-style: none;
    margin: 0;
    padding: 8px;
}

.ht-header-user-links li a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    color: var(--ht-header-text);
    font-size: 14px;
    text-decoration: none;
    border-radius: var(--ht-header-radius);
    transition: background var(--ht-header-transition);
}

.ht-header-user-links li a:hover {
    background: var(--ht-header-hover-bg);
}

.dark-only .ht-header-user-links li a {
    color: var(--ht-header-text-dark);
}

.dark-only .ht-header-user-links li a:hover {
    background: var(--ht-header-hover-bg-dark);
}

.ht-header-user-links li a svg {
    width: 18px;
    height: 18px;
    color: var(--ht-header-text-muted);
}

.dark-only .ht-header-user-links li a svg {
    color: var(--ht-header-text-muted-dark);
}

.ht-header-user-divider {
    height: 1px;
    background: var(--ht-header-border);
    margin: 8px 0;
}

.dark-only .ht-header-user-divider {
    background: var(--ht-header-border-dark);
}

.ht-header-logout {
    color: var(--ht-color-danger) !important;
}

.ht-header-logout:hover {
    background: rgba(239, 68, 68, 0.08) !important;
}

.ht-header-logout svg {
    color: var(--ht-color-danger) !important;
}

/* ===========================================
   RESPONSIVE - Tablet (max 1199px)
   =========================================== */
@media (max-width: 1199px) {
    .ht-header {
        left: 0 !important;
        right: 0 !important;
    }
    
    [dir="rtl"] .ht-header {
        left: 0 !important;
        right: 0 !important;
    }
    
    .ht-header-logo {
        display: flex;
        align-items: center;
    }
    
    .ht-header-center {
        display: flex;
        overflow: hidden;
    }

    /* On tablet, hide intermediate crumbs — show only home + current */
    .ht-breadcrumb-item:not(:first-child):not(.ht-breadcrumb-current) {
        display: none;
    }
    
    /* Show an ellipsis indicator between home and current */
    .ht-breadcrumb-current .ht-breadcrumb-sep {
        display: flex;
    }

    /* Add ellipsis dots before the chevron to indicate collapsed crumbs */
    .ht-breadcrumb-current .ht-breadcrumb-sep::before {
        content: '\2026';
        margin-inline-end: 4px;
        color: var(--ht-header-text-muted);
        font-size: 14px;
        font-weight: 600;
        letter-spacing: 1px;
    }

    .ht-breadcrumb-text {
        max-width: 180px;
    }
}

/* ===========================================
   RESPONSIVE - Mobile (max 767px)
   =========================================== */
@media (max-width: 767px) {
    .ht-header-inner {
        padding: 0 12px;
        gap: 8px;
    }
    
    /* Hide breadcrumb on mobile — not enough space */
    .ht-header-center {
        display: none;
    }
    
    .ht-header-user-name {
        display: none;
    }
    
    .ht-header-chevron {
        display: none;
    }
    
    .ht-header-user-trigger {
        padding: 0 8px !important;
    }
    
    .ht-header-lang-label {
        display: none;
    }
    
    .ht-header-dropdown-menu {
        position: fixed;
        top: var(--ht-header-height);
        left: 8px;
        right: 8px;
        max-width: none;
        width: auto;
    }
    
    [dir="rtl"] .ht-header-dropdown-menu {
        left: 8px;
        right: 8px;
    }
    
    .ht-header-notifications-menu {
        width: auto;
    }
}

/* ===========================================
   RESPONSIVE - Small Mobile (max 480px)
   =========================================== */
@media (max-width: 480px) {
    .ht-header-logo-img {
        height: 28px;
    }
    
    .ht-header-item > button,
    .ht-header-item > a,
    .ht-header-dropdown-trigger {
        min-width: 36px;
        height: 36px;
        padding: 0 8px;
    }
    
    .ht-header-icon {
        width: 18px;
        height: 18px;
    }
    
    .ht-header-avatar {
        width: 28px;
        height: 28px;
    }
}

/* ===========================================
   HIDE OLD HEADER ELEMENTS
   =========================================== */
.page-wrapper .page-header {
    display: none !important;
}

/* ===========================================
   PAGE BODY ADJUSTMENT
   =========================================== */
.page-wrapper .page-body-wrapper {
    padding-top: var(--ht-header-height) !important;
}

.page-wrapper .page-body-wrapper .page-body {
    margin-top: 0 !important;
}
