/* Radzen Header Components Custom Styling */

/* Ensure header alignment */
.app-header {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    height: 64px !important;
    max-height: 64px !important;
    padding: 0 1.25rem !important;
    overflow: visible !important;
}

.header-left {
    display: flex !important;
    align-items: center !important;
    gap: 1rem !important;
}

.header-right {
    display: flex !important;
    align-items: center !important;
    gap: 0.75rem !important;
    height: 100% !important;
    max-height: 64px !important;
    overflow: visible !important;
}

/* Sidebar Toggle Button */
.sidebar-toggle {
    background: transparent !important;
    border: none !important;
    color: #0071c1 !important;
    padding: 0.5rem !important;
    border-radius: 4px !important;
    transition: all 0.3s ease !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    height: 40px !important;
    width: 40px !important;
}

.sidebar-toggle:hover {
    background-color: rgba(0, 113, 193, 0.1) !important;
    transform: scale(1.05) !important;
}

/* Mobile Menu Toggle */
.mobile-menu-toggle {
    background: transparent !important;
    border: none !important;
    color: #0071c1 !important;
    padding: 0.5rem !important;
    border-radius: 4px !important;
    display: none !important;
    align-items: center !important;
    justify-content: center !important;
    height: 40px !important;
    width: 40px !important;
}

@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: flex !important;
    }
}

/* Notification Button */
.notification-btn {
    background: transparent !important;
    border: none !important;
    color: #0071c1 !important;
    padding: 0.5rem !important;
    border-radius: 4px !important;
    position: relative !important;
    transition: all 0.3s ease !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    height: 40px !important;
    width: 40px !important;
}

.notification-btn:hover {
    background-color: rgba(0, 113, 193, 0.1) !important;
}

/* Notification Panel */
.notification-panel {
    position: absolute !important;
    top: 100% !important;
    right: 0 !important;
    width: 320px !important;
    max-height: 400px !important;
    overflow-y: auto !important;
    z-index: 1000 !important;
    border: 1px solid #e0e0e0 !important;
    border-radius: 8px !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
    background: white !important;
    margin-top: 0.5rem !important;
}

.notification-header {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 1rem !important;
    border-bottom: 1px solid #e0e0e0 !important;
}

.notification-header h6 {
    margin: 0 !important;
    font-weight: 600 !important;
    color: #333 !important;
}

.notification-list {
    padding: 0 !important;
}

.notification-item {
    display: flex !important;
    align-items: flex-start !important;
    padding: 1rem !important;
    border-bottom: 1px solid #f0f0f0 !important;
    transition: background-color 0.2s ease !important;
}

.notification-item:hover {
    background-color: #f8f9fa !important;
}

.notification-item.unread {
    background-color: rgba(0, 113, 193, 0.05) !important;
}

.notification-item i {
    color: #0071c1 !important;
    margin-left: 0.75rem !important;
    margin-top: 0.25rem !important;
    font-size: 1rem !important;
}

.notification-content p {
    margin: 0 0 0.25rem 0 !important;
    font-size: 0.9rem !important;
    color: #333 !important;
}

.notification-content small {
    color: #666 !important;
    font-size: 0.8rem !important;
}

/* Theme Toggle Button */
.theme-toggle {
    background: transparent !important;
    border: none !important;
    color: #0071c1 !important;
    padding: 0.5rem !important;
    border-radius: 4px !important;
    transition: all 0.3s ease !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    height: 40px !important;
    width: 40px !important;
}

.theme-toggle:hover {
    background-color: rgba(0, 113, 193, 0.1) !important;
    transform: scale(1.05) !important;
}

/* User Button — compact, fits 64px header */
.user-btn {
    background: #f8fafc !important;
    border: 1px solid #e2e8f0 !important;
    color: #334155 !important;
    padding: 0 0.5rem 0 0.35rem !important;
    border-radius: 8px !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 0.4rem !important;
    height: 36px !important;
    min-height: 36px !important;
    max-height: 36px !important;
    min-width: 0 !important;
    width: auto !important;
    box-shadow: none !important;
    line-height: 1.1 !important;
    overflow: hidden !important;
    transition: background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease !important;
}

.user-btn:hover {
    background-color: #f1f5f9 !important;
    border-color: #cbd5e1 !important;
    color: #1e293b !important;
    transform: none !important;
}

.user-btn.is-open {
    background: #eff6ff !important;
    border-color: #93c5fd !important;
    box-shadow: 0 0 0 2px rgba(0, 113, 193, 0.1) !important;
}

.user-btn .user-avatar {
    width: 26px !important;
    height: 26px !important;
    border-radius: 50% !important;
    background: linear-gradient(135deg, #0071c1 0%, #005a9e 100%) !important;
    color: #fff !important;
    font-size: 0.625rem !important;
    font-weight: 700 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
}

.user-btn .user-info {
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    justify-content: center !important;
    max-width: 7.5rem !important;
    min-width: 0 !important;
    gap: 0 !important;
    line-height: 1.15 !important;
}

.user-btn .user-name {
    font-size: 0.75rem !important;
    font-weight: 600 !important;
    color: #1e293b !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    max-width: 100% !important;
    line-height: 1.15 !important;
}

.user-btn .user-role {
    font-size: 0.625rem !important;
    font-weight: 500 !important;
    color: #64748b !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    max-width: 100% !important;
    line-height: 1.15 !important;
    background: none !important;
    border: none !important;
    padding: 0 !important;
    border-radius: 0 !important;
    margin: 0 !important;
}

.user-btn .user-chevron {
    font-size: 0.55rem !important;
    color: #94a3b8 !important;
    transition: transform 0.2s ease !important;
    flex-shrink: 0 !important;
}

.user-btn.is-open .user-chevron {
    transform: rotate(180deg) !important;
    color: #0071c1 !important;
}

/* User Menu — fixed + JS-clamped so it never leaves the viewport */
.user-menu-backdrop {
    position: fixed !important;
    inset: 0 !important;
    z-index: 1090 !important;
    background: transparent !important;
}

.user-menu {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: auto !important;
    width: 260px !important;
    min-width: 260px !important;
    max-width: min(260px, calc(100vw - 24px)) !important;
    z-index: 1100 !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 12px !important;
    box-shadow: 0 10px 32px rgba(15, 23, 42, 0.14) !important;
    background: #fff !important;
    padding: 0 !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    animation: user-menu-in 0.14s ease-out !important;
    transform-origin: top left !important;
    visibility: hidden;
}

@keyframes user-menu-in {
    from {
        opacity: 0;
        transform: translateY(-6px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.user-menu-header {
    padding: 0.75rem 0.85rem !important;
    text-align: right !important;
    background: #f8fafc !important;
    color: inherit !important;
    position: relative !important;
    overflow: visible !important;
    display: flex !important;
    align-items: center !important;
    gap: 0.65rem !important;
    border-bottom: 1px solid #f1f5f9 !important;
}

.user-menu-header::before {
    display: none !important;
}

.user-avatar-large {
    width: 2.25rem !important;
    height: 2.25rem !important;
    border-radius: 50% !important;
    background: linear-gradient(135deg, #0071c1 0%, #005a9e 100%) !important;
    backdrop-filter: none !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    margin: 0 !important;
    border: none !important;
    color: #fff !important;
    font-size: 0.75rem !important;
    font-weight: 700 !important;
    flex-shrink: 0 !important;
}

.user-avatar-large i {
    font-size: 1rem !important;
    color: white !important;
}

.user-details {
    position: relative !important;
    z-index: 1 !important;
    flex: 1 !important;
    min-width: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 0.15rem !important;
}

.user-details .user-name {
    font-weight: 700 !important;
    font-size: 0.9375rem !important;
    margin-bottom: 0 !important;
    display: block !important;
    text-shadow: none !important;
    color: #0f172a !important;
}

.user-details .user-email {
    font-size: 0.75rem !important;
    opacity: 1 !important;
    margin-bottom: 0 !important;
    display: block !important;
    font-weight: 400 !important;
    color: #64748b !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    max-width: 100% !important;
    direction: ltr !important;
}

.user-details .user-role {
    font-size: 0.6875rem !important;
    font-weight: 600 !important;
    display: inline-block !important;
    background: #eff6ff !important;
    color: #0071c1 !important;
    padding: 0.15rem 0.5rem !important;
    border-radius: 999px !important;
    backdrop-filter: none !important;
    border: 1px solid #dbeafe !important;
    text-shadow: none !important;
    box-shadow: none !important;
    margin-top: 0.2rem !important;
}

.user-menu-items {
    padding: 0.4rem !important;
    background: white !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 0.1rem !important;
}

.menu-item {
    width: 100% !important;
    text-align: right !important;
    padding: 0.55rem 0.7rem !important;
    background: transparent !important;
    border: none !important;
    color: #334155 !important;
    font-size: 0.8125rem !important;
    font-weight: 500 !important;
    transition: background-color 0.15s ease, color 0.15s ease !important;
    display: flex !important;
    align-items: center !important;
    gap: 0.65rem !important;
    position: relative !important;
    border-radius: 8px !important;
    margin: 0 !important;
    min-height: 0 !important;
    box-shadow: none !important;
    justify-content: flex-start !important;
}

.menu-item:hover {
    background-color: #f1f5f9 !important;
    color: #0f172a !important;
    transform: none !important;
}

.menu-item:active {
    background-color: #e2e8f0 !important;
    transform: none !important;
}

.menu-item i,
.menu-item .rz-button-icon {
    font-size: 0.9rem !important;
    width: 1rem !important;
    text-align: center !important;
    color: #64748b !important;
}

.menu-item:hover i {
    color: #0071c1 !important;
}

/* Legacy Radzen button menu-item overrides (safe no-ops if unused) */
.user-menu .rz-button.menu-item {
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    border-radius: 10px !important;
    margin: 0 !important;
    padding: 0.7rem 0.75rem !important;
    width: 100% !important;
    text-align: right !important;
    justify-content: flex-start !important;
    font-weight: 500 !important;
    font-size: 0.875rem !important;
    color: #334155 !important;
    transition: background-color 0.15s ease !important;
    min-height: 0 !important;
}

.user-menu .rz-button.menu-item:hover {
    background-color: #f1f5f9 !important;
    color: #0f172a !important;
    transform: none !important;
    box-shadow: none !important;
}

.user-menu .rz-button.menu-item:active {
    background-color: #e2e8f0 !important;
    transform: none !important;
}

.user-menu .rz-button.menu-item.logout-btn,
.menu-item.logout-btn {
    color: #dc2626 !important;
    border-top: none !important;
    margin-top: 0 !important;
    padding-top: 0.7rem !important;
}

.user-menu .rz-button.menu-item.logout-btn:hover,
.menu-item.logout-btn:hover {
    background-color: #fef2f2 !important;
    color: #b91c1c !important;
}

.user-menu .rz-button.menu-item.logout-btn:active,
.menu-item.logout-btn:active {
    background-color: #fee2e2 !important;
}

.menu-item.logout-btn i {
    color: #dc2626 !important;
}

.menu-divider {
    height: 1px !important;
    background: #f1f5f9 !important;
    margin: 0.35rem 0.5rem !important;
}

/* Dark Theme Support - Enhanced */
[data-theme="dark"] .user-menu {
    background: #1f2937 !important;
    border-color: #374151 !important;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35) !important;
}

[data-theme="dark"] .user-menu-header {
    background: linear-gradient(180deg, #111827 0%, #1f2937 100%) !important;
    border-bottom-color: #374151 !important;
}

[data-theme="dark"] .user-details .user-name {
    color: #f9fafb !important;
}

[data-theme="dark"] .user-details .user-email {
    color: #9ca3af !important;
}

[data-theme="dark"] .user-details .user-role {
    background: rgba(96, 165, 250, 0.15) !important;
    border-color: rgba(96, 165, 250, 0.3) !important;
    color: #93c5fd !important;
}

[data-theme="dark"] .user-menu-items {
    background: #1f2937 !important;
}

[data-theme="dark"] .menu-item {
    color: #d1d5db !important;
}

[data-theme="dark"] .menu-item:hover {
    background-color: #374151 !important;
    color: #f9fafb !important;
}

[data-theme="dark"] .menu-item:active {
    background-color: #4b5563 !important;
}

[data-theme="dark"] .menu-item.logout-btn {
    color: #f87171 !important;
    border-top-color: transparent !important;
}

[data-theme="dark"] .menu-item.logout-btn:hover {
    background-color: rgba(127, 29, 29, 0.35) !important;
    color: #fca5a5 !important;
}

[data-theme="dark"] .menu-item.logout-btn:active {
    background-color: rgba(153, 27, 27, 0.45) !important;
}

[data-theme="dark"] .menu-divider {
    background: #374151 !important;
}

/* Dark Theme Support for other components */
[data-theme="dark"] .notification-panel {
    background: #1f2937;
    border-color: #374151;
}

[data-theme="dark"] .notification-header {
    border-bottom-color: #374151;
}

[data-theme="dark"] .notification-header h6 {
    color: #d1d5db;
}

[data-theme="dark"] .notification-item {
    border-bottom-color: #374151;
}

[data-theme="dark"] .notification-item:hover {
    background-color: #374151;
}

[data-theme="dark"] .notification-content p {
    color: #d1d5db;
}

[data-theme="dark"] .notification-content small {
    color: #9ca3af;
}

[data-theme="dark"] .sidebar-toggle,
[data-theme="dark"] .mobile-menu-toggle,
[data-theme="dark"] .notification-btn,
[data-theme="dark"] .theme-toggle {
    color: #60a5fa;
}

[data-theme="dark"] .sidebar-toggle:hover,
[data-theme="dark"] .mobile-menu-toggle:hover,
[data-theme="dark"] .notification-btn:hover,
[data-theme="dark"] .theme-toggle:hover {
    background-color: rgba(96, 165, 250, 0.1);
}

[data-theme="dark"] .user-btn {
    background: #1f2937 !important;
    border-color: #374151 !important;
    color: #e5e7eb !important;
}

[data-theme="dark"] .user-btn:hover {
    background-color: #374151 !important;
    border-color: #4b5563 !important;
    color: #f9fafb !important;
}

[data-theme="dark"] .user-btn.is-open {
    background: rgba(96, 165, 250, 0.12) !important;
    border-color: rgba(96, 165, 250, 0.45) !important;
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.15) !important;
}

[data-theme="dark"] .user-btn .user-name {
    color: #f3f4f6 !important;
}

[data-theme="dark"] .user-btn .user-role {
    color: #9ca3af !important;
}

/* Responsive Design - Improved */
@media (max-width: 768px) {
    .notification-panel {
        width: 280px;
        right: -50px;
    }

    .user-btn {
        min-width: 36px !important;
        width: 36px !important;
        height: 36px !important;
        max-height: 36px !important;
        padding: 0 !important;
        border-radius: 8px !important;
        gap: 0 !important;
        justify-content: center !important;
    }

    .user-btn .user-info,
    .user-btn .user-chevron {
        display: none !important;
    }

    .user-menu {
        width: min(260px, calc(100vw - 24px)) !important;
        min-width: 0 !important;
        max-width: min(260px, calc(100vw - 24px)) !important;
    }
}

@media (max-width: 480px) {
    .notification-panel {
        width: 260px;
        right: -80px;
    }
    
    .user-menu {
        width: min(260px, calc(100vw - 24px)) !important;
        min-width: 0 !important;
        max-width: min(260px, calc(100vw - 24px)) !important;
    }
}

/* Persian Digits Support */
.notification-panel *,
.user-menu * {
    font-feature-settings: "ss01" 1, "tnum" 0 !important;
    -webkit-font-feature-settings: "ss01" 1, "tnum" 0 !important;
    -moz-font-feature-settings: "ss01" 1, "tnum" 0 !important;
}

/* Dark theme overrides for Radzen buttons */
[data-theme="dark"] .user-menu .rz-button.menu-item {
    color: #d1d5db !important;
}

[data-theme="dark"] .user-menu .rz-button.menu-item:hover {
    background-color: #374151 !important;
    color: #60a5fa !important;
}

[data-theme="dark"] .user-menu .rz-button.menu-item:active {
    background-color: #4b5563 !important;
}

[data-theme="dark"] .user-menu .rz-button.menu-item.logout-btn {
    color: #f87171 !important;
    border-top-color: #374151 !important;
}

[data-theme="dark"] .user-menu .rz-button.menu-item.logout-btn:hover {
    background-color: #7f1d1d !important;
    color: #fca5a5 !important;
}

[data-theme="dark"] .user-menu .rz-button.menu-item.logout-btn:active {
    background-color: #991b1b !important;
}
