/*
=================================================================
ENHANCED HEADER DROPDOWN STYLES - HARMONIZED WITH SIDEBAR (v4)
- Philosophy: Visual harmony with sidebar design system
- INTEGRATION: Uses sidebar CSS variables and design patterns
- ENHANCEMENTS:
  - Unified color scheme and effects with sidebar
  - Enhanced gradients and backdrop filters
  - Improved spacing and proportions
  - Smooth animations and micro-interactions
  - Full responsive design
  - Enhanced accessibility
=================================================================
*/

/* ===== Import Sidebar Variables ===== */
/* Note: These variables are inherited from the sidebar.css */

/* ===== Accessibility Helpers ===== */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ===== Admin Dropdown Container ===== */
.admin-dropdown {
    position: relative;
    display: flex;
    align-items: center;
    z-index: var(--z-header, 300);
    margin-inline-start: auto;  /* در RTL: margin-right:auto → دکمه را تا انتهای چپ هل می‌دهد */
}

/* ===== Hide dropdown-menu by default (Bootstrap grid-only CSS doesn't include this) ===== */
.admin-dropdown .dropdown-menu {
    display: none;
}

.admin-dropdown .dropdown-menu.show {
    display: block;
}

/* ===== Profile Avatar Button (Social Media Style) ===== */
.profile-avatar-btn {
    background: transparent;
    border: none;
    padding: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: transform 0.2s ease;
}

.profile-avatar-btn::after {
    display: none;
    /* Remove bootstrap dropdown arrow */
}

.profile-avatar-btn:hover {
    transform: scale(1.05);
}

.profile-avatar-btn:active {
    transform: scale(0.98);
}

/* Avatar Circle - matching sidebar toggle button */
.avatar-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--sidebar-primary-15) 0%, var(--sidebar-primary-dark-10) 50%, var(--sidebar-primary-08) 100%);
    border: 1px solid var(--sidebar-white-15);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(8px);
}

.avatar-circle i {
    color: var(--sidebar-text);
    font-size: 1.1rem;
}

.profile-avatar-btn:hover .avatar-circle {
    background: linear-gradient(135deg, var(--sidebar-primary) 0%, var(--sidebar-primary-dark) 100%);
    border-color: var(--sidebar-white-25);
    box-shadow: 0 4px 16px var(--sidebar-primary-30);
}

.profile-avatar-btn:hover .avatar-circle i {
    color: white;
}

.profile-avatar-btn:focus .avatar-circle {
    outline: none;
    box-shadow: 0 0 0 3px var(--sidebar-primary-30);
}

/* ===== Main Dropdown Container ===== */
.enhanced-dropdown {
    --dropdown-padding: 0;
    --item-horizontal-padding: 1rem;
    --item-vertical-padding: 0.75rem;
    background: #052136;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    padding: 0;
    margin-top: 0.5rem !important;
    backdrop-filter: blur(20px);
    min-width: 200px;
    max-width: 240px;
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity 0.2s ease-out, transform 0.2s ease-out;
    will-change: transform, opacity;
    position: relative;
    overflow: visible;
    direction: rtl;
    font-family: inherit;
}

.enhanced-dropdown.show {
    opacity: 1;
    transform: translateY(0);
}

/* Arrow/Caret at top of dropdown - aligned with avatar center (6 o'clock) */
.enhanced-dropdown::before {
    content: '';
    position: absolute;
    top: -8px;
    left: 28px;
    right: auto;
    transform: none;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 8px solid #052136;
    z-index: 1;
}

.enhanced-dropdown::after {
    content: '';
    position: absolute;
    top: -9px;
    left: 27px;
    right: auto;
    transform: none;
    width: 0;
    height: 0;
    border-left: 9px solid transparent;
    border-right: 9px solid transparent;
    border-bottom: 9px solid rgba(255, 255, 255, 0.1);
    z-index: 0;
}

/* ===== Dropdown Header - User Info ===== */
.enhanced-dropdown-header {
    padding: 1.25rem 1rem 1rem;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    background: transparent;
}

.enhanced-dropdown-header::before {
    display: none;
}

.user-header-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.user-header-name {
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.95);
    line-height: 1.4;
}

.user-header-role {
    font-family: inherit;
    font-size: 0.7rem;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.5);
    line-height: 1.3;
}

/* ===== Dropdown Items (Links) ===== */
.enhanced-dropdown-item {
    display: flex;
    flex-direction: row-reverse;
    align-items: center;
    justify-content: flex-end;
    gap: 0.875rem;
    padding: var(--item-vertical-padding) var(--item-horizontal-padding);
    color: rgba(255, 255, 255, 0.85);
    border-radius: 0;
    transition: all 0.15s ease;
    text-decoration: none;
    border: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    background: transparent;
    margin: 0;
    position: relative;
}

.enhanced-dropdown-item:last-child,
.enhanced-dropdown li:last-child .enhanced-dropdown-item {
    border-bottom: none;
}

.enhanced-dropdown-item::before {
    display: none;
}

/* Override Bootstrap defaults */
.dropdown-item:focus,
.dropdown-item:hover {
    background-color: transparent;
    color: rgba(255, 255, 255, 0.95);
}

/* Hover & Focus States */
.enhanced-dropdown-item:hover,
.enhanced-dropdown-item:focus-visible {
    background: rgba(255, 255, 255, 0.05);
    color: white;
    outline: none;
    transform: none;
}

/* Active effect */
.enhanced-dropdown-item:active {
    background: rgba(255, 255, 255, 0.08);
}

/* ===== Dropdown Item Icons ===== */
.enhanced-dropdown-item i {
    min-width: 1.25rem;
    width: 1.25rem;
    height: 1.25rem;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0;
    background: transparent;
    border: none;
    color: var(--sidebar-primary);
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.enhanced-dropdown-item:hover i,
.enhanced-dropdown-item:focus-visible i {
    color: var(--sidebar-primary-dark);
    transform: scale(1.1);
}

/* ===== Dropdown Item Text ===== */
.enhanced-dropdown-item span {
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.15s ease;
    white-space: nowrap;
    line-height: 1.4;
    flex: 1;
    text-align: right;
}

.enhanced-dropdown-item:hover span,
.enhanced-dropdown-item:focus-visible span {
    color: white;
}

/* ===== Divider ===== */
.enhanced-dropdown-divider {
    height: 1px;
    margin: 0;
    background: rgba(255, 255, 255, 0.06);
    border: none;
}

.enhanced-dropdown-divider::before {
    display: none;
}

/* ===== Logout Button ===== */
.enhanced-dropdown-item-logout {
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    border-bottom: none !important;
}

.enhanced-dropdown-item-logout i {
    color: rgba(255, 255, 255, 0.6);
}

.enhanced-dropdown-item-logout:hover {
    background: rgba(255, 255, 255, 0.05);
}

.enhanced-dropdown-item-logout:hover i {
    color: rgba(255, 255, 255, 0.8);
}

/* ===== Special Item (Logout Button) ===== */
.enhanced-dropdown-item-danger {
    border-color: rgba(229, 57, 53, 0.2);
}

.enhanced-dropdown-item-danger:hover {
    --danger-color: #e53935;
    background: linear-gradient(135deg, rgba(229, 57, 53, 0.2) 0%, rgba(229, 57, 53, 0.15) 50%, rgba(229, 57, 53, 0.1) 100%);
    color: var(--danger-color);
    border-color: rgba(229, 57, 53, 0.3);
    box-shadow: 0 4px 12px rgba(229, 57, 53, 0.2);
}

.enhanced-dropdown-item-danger:hover i {
    background: rgba(229, 57, 53, 0.25);
    color: var(--danger-color);
    border-color: rgba(229, 57, 53, 0.4);
}

.enhanced-dropdown-item-danger:hover span {
    color: var(--danger-color);
    font-weight: var(--sidebar-font-weight-semibold);
}

/* ===== Enhanced Animations ===== */
@keyframes slideInFromRight {
    from {
        opacity: 0;
        transform: translateX(20px) translateY(-5px);
    }

    to {
        opacity: 1;
        transform: translateX(0) translateY(0);
    }
}

/* ===== Responsive Design ===== */
@media (max-width: 768px) {
    .enhanced-dropdown {
        min-width: 180px;
        max-width: 200px;
        margin-top: 0.5rem !important;
        --dropdown-padding: 0.25rem;
        --item-horizontal-padding: 0.625rem;
        --item-vertical-padding: 0.4rem;
    }

    .admin-profile-btn {
        padding: 0.375rem 0.625rem;
        font-size: 0.75rem;
    }

    .enhanced-dropdown-item {
        padding: var(--item-vertical-padding) var(--item-horizontal-padding);
        margin: 0.1rem 0;
    }

    .enhanced-dropdown-item i {
        min-width: 1.25rem;
        width: 1.25rem;
        height: 1.25rem;
        font-size: 0.75rem;
    }

    .enhanced-dropdown-item span {
        font-size: 0.75rem;
    }

    .enhanced-dropdown-header {
        font-size: 0.625rem;
        padding: 0.625rem var(--item-horizontal-padding) 0.375rem;
        margin-bottom: 0.375rem;
    }
}

@media (max-width: 480px) {
    .enhanced-dropdown {
        min-width: 220px;
        max-width: 250px;
        --dropdown-padding: 0.25rem;
    }

    .admin-profile-btn {
        padding: 0.375rem 0.625rem;
        font-size: 0.75rem;
    }

    .enhanced-dropdown-item {
        gap: 0.625rem;
    }

    .enhanced-dropdown-item span {
        font-size: 0.75rem;
    }
}

/* ===== Enhanced Accessibility ===== */
/* Focus management for keyboard navigation */
.enhanced-dropdown-item:focus-visible,
.admin-profile-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--sidebar-primary), 0 0 0 4px var(--sidebar-primary-30), 0 4px 16px var(--sidebar-primary-20);
    border-radius: var(--sidebar-border-radius);
}

.admin-profile-btn:focus-visible {
    box-shadow: 0 0 0 2px var(--sidebar-primary), 0 0 0 4px var(--sidebar-primary-30), 0 4px 16px var(--sidebar-primary-20), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .enhanced-dropdown-item i {
        border: 2px solid currentColor;
        background: transparent;
    }

    .enhanced-dropdown-item-danger {
        border-color: #e53935;
    }

    .enhanced-dropdown-item-danger:hover {
        background: rgba(229, 57, 53, 0.3);
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {

    .enhanced-dropdown,
    .enhanced-dropdown-item,
    .admin-profile-btn,
    .enhanced-dropdown-item i,
    .enhanced-dropdown-item span {
        animation: none !important;
        transition: none !important;
    }

    .enhanced-dropdown-item::before,
    .admin-profile-btn::before {
        display: none !important;
    }

    .enhanced-dropdown-item:hover,
    .enhanced-dropdown-item:focus-visible,
    .admin-profile-btn:hover,
    .admin-profile-btn:focus-visible {
        transform: none !important;
    }
}

/* ===== Performance Optimizations ===== */
.enhanced-dropdown-item,
.enhanced-dropdown-item i,
.enhanced-dropdown-item span,
.admin-profile-btn {
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    -webkit-font-smoothing: antialiased;
    transform: translateZ(0);
}

/* Prevent text selection on interactive elements */
.admin-profile-btn,
.enhanced-dropdown-item {
    -webkit-user-select: none;
    -moz-user-select: none;
    user-select: none;
}

/* Ensure proper stacking context */
.enhanced-dropdown {
    isolation: isolate;
}