/* ============================================================================
   Lions User Manager - Enhanced Custom Topbar Styles

   Auteur: Lions User Manager
   Version: 2.0.0
   Description: Styles améliorés pour la topbar avec intégration intelligente
                des patterns Freya layout pour un rendu parfait

   Intégrations:
   - Freya Layout Variables & Patterns
   - Support Dark/Light Theme
   - Animations fluides (fadeInDown, modal-in)
   - PrimeFlex utility classes
   - Responsive design
   ============================================================================ */

/* ----------------------------------------------------------------------------
   BASE TOPBAR LAYOUT OVERRIDES
   Améliore la structure de base de la topbar Freya
   ---------------------------------------------------------------------------- */

.layout-topbar {
    position: fixed;
    top: 0;
    z-index: 999;
    width: 100%;
    height: 62px;
    transition: width 0.2s, box-shadow 0.3s ease;
}

.layout-topbar .layout-topbar-wrapper {
    height: 100%;
    display: flex;
    align-items: center;
}

.layout-topbar .layout-topbar-wrapper .layout-topbar-right {
    height: 100%;
    flex-grow: 1;
    padding: 0 16px 0 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.layout-topbar .layout-topbar-wrapper .layout-topbar-right .layout-topbar-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-grow: 1;
    list-style-type: none;
    margin: 0;
    padding: 0;
    height: 100%;
}

.layout-topbar .layout-topbar-wrapper .layout-topbar-right .layout-topbar-actions > li {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}

/* ----------------------------------------------------------------------------
   USER PROFILE LINK - Enhanced with Freya patterns
   ---------------------------------------------------------------------------- */

.layout-topbar .user-profile-link {
    display: flex !important;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    transition: all 0.2s cubic-bezier(0.05, 0.74, 0.2, 0.99);
    text-decoration: none;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.layout-topbar .user-profile-link::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
    opacity: 0;
    transition: opacity 0.2s ease;
}

.layout-topbar .user-profile-link:hover::before {
    opacity: 1;
}

.layout-topbar .user-profile-link:hover {
    background-color: rgba(255, 255, 255, 0.12);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* User Avatar - Integration with Freya avatar patterns */
.layout-topbar .user-profile-link .user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.layout-topbar .user-profile-link:hover .user-avatar {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* User Info Container */
.layout-topbar .user-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.2;
    min-width: 0;
}

/* User Name - Enhanced typography */
.layout-topbar .user-name {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-color);
    margin-bottom: 0.125rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

/* User Email */
.layout-topbar .user-email {
    font-size: 0.75rem;
    color: var(--text-color-secondary);
    opacity: 0.85;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

/* User Role Badge */
.layout-topbar .user-role {
    font-size: 0.7rem;
    color: var(--primary-color);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    background: rgba(var(--primary-color-rgb, 79, 142, 236), 0.1);
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
    white-space: nowrap;
}

.layout-topbar .user-separator {
    color: var(--text-color-secondary);
    opacity: 0.5;
    font-weight: 300;
    margin: 0 0.25rem;
}

/* Online Status Indicator */
.layout-topbar .user-status {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    position: relative;
}

.layout-topbar .user-status.online {
    background-color: #4CAF50;
    box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.3);
    animation: pulse-online 2s ease-in-out infinite;
}

@keyframes pulse-online {
    0%, 100% {
        box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.3);
    }
    50% {
        box-shadow: 0 0 0 4px rgba(76, 175, 80, 0.2);
    }
}

/* ----------------------------------------------------------------------------
   USER DROPDOWN MENU - Enhanced with Freya dropdown patterns
   ---------------------------------------------------------------------------- */

.layout-topbar .user-dropdown-menu {
    display: none;
    position: absolute;
    top: 62px;
    right: 0;
    min-width: 280px;
    max-width: 320px;
    padding: 0;
    margin: 0;
    list-style-type: none;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12), 0 2px 6px rgba(0, 0, 0, 0.08);
    border: 1px solid var(--surface-border);
    background: var(--surface-card);
    overflow: hidden;
    z-index: 1000;
    animation-duration: 0.2s;
    animation-timing-function: cubic-bezier(0.05, 0.74, 0.2, 0.99);
    animation-fill-mode: forwards;
}

/* Show dropdown when parent is active */
.layout-topbar .user-profile.active-topmenuitem > .user-dropdown-menu {
    display: block;
    animation-name: fadeInDown;
}

/* Dropdown Header - Integration with Freya gradient patterns */
.user-dropdown-header {
    padding: 1.25rem 1rem;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-600, #387FE9));
    color: white;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    position: relative;
    overflow: hidden;
}

.user-dropdown-header::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 70%);
    animation: shimmer 3s ease-in-out infinite;
}

@keyframes shimmer {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(-20%, -20%); }
}

/* Dropdown Avatar */
.user-dropdown-avatar {
    position: relative;
    flex-shrink: 0;
}

.user-dropdown-avatar > div {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.user-status-indicator {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid white;
}

.user-status-indicator.online {
    background-color: #4CAF50;
    animation: pulse-indicator 2s ease-in-out infinite;
}

@keyframes pulse-indicator {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Dropdown User Info */
.user-dropdown-info {
    flex: 1;
    min-width: 0;
}

.user-dropdown-name {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 0.25rem;
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-dropdown-email {
    font-size: 0.875rem;
    opacity: 0.95;
    margin-bottom: 0.25rem;
    color: rgba(255, 255, 255, 0.95);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-dropdown-role {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: rgba(255, 255, 255, 0.25);
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    display: inline-block;
    color: white;
    backdrop-filter: blur(10px);
}

/* Dividers */
.user-dropdown-divider {
    height: 1px;
    background-color: var(--surface-border);
    margin: 0;
}

/* Menu Sections */
.user-dropdown-section {
    padding: 0.75rem 0;
}

.section-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-color-secondary);
    padding: 0 1rem 0.5rem 1rem;
    margin-bottom: 0.25rem;
}

.section-items {
    display: flex;
    flex-direction: column;
}

/* Dropdown Items - Enhanced with Freya interaction patterns */
.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text-color);
    text-decoration: none;
    transition: all 0.2s cubic-bezier(0.05, 0.74, 0.2, 0.99);
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    position: relative;
    overflow: hidden;
}

.dropdown-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: 3px;
    height: 100%;
    background: var(--primary-color);
    transform: scaleX(0);
    transition: transform 0.2s ease;
}

.dropdown-item:hover::before {
    transform: scaleX(1);
}

.dropdown-item:hover {
    background-color: var(--surface-hover);
    color: var(--primary-color);
    padding-left: 1.25rem;
}

.dropdown-item:active {
    background-color: var(--surface-ground);
    transform: scale(0.98);
}

.dropdown-item i {
    width: 1.25rem;
    text-align: center;
    color: var(--text-color-secondary);
    transition: all 0.2s ease;
    font-size: 1rem;
}

.dropdown-item:hover i {
    color: var(--primary-color);
    transform: scale(1.1);
}

.dropdown-item span {
    flex: 1;
}

.item-arrow {
    margin-left: auto;
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
    font-size: 0.75rem;
}

.dropdown-item:hover .item-arrow {
    opacity: 1;
    transform: translateX(4px);
}

/* Logout Item - Enhanced danger state */
.logout-item {
    color: var(--red-500) !important;
    margin-top: 0.25rem;
}

.logout-item:hover {
    background-color: var(--red-50) !important;
    color: var(--red-600) !important;
}

.logout-item i {
    color: var(--red-500) !important;
}

.logout-item:hover i {
    color: var(--red-600) !important;
    transform: scale(1.1) rotate(-5deg);
}

/* ----------------------------------------------------------------------------
   ANIMATIONS - Integration with Freya animation patterns
   ---------------------------------------------------------------------------- */

@keyframes dropdownFadeIn {
    0% {
        opacity: 0;
        transform: translateY(-10px) scale(0.95);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.user-dropdown-menu {
    animation: dropdownFadeIn 0.3s ease-out;
    transform-origin: top right;
}

/* ----------------------------------------------------------------------------
   DARK MODE SUPPORT - Integration with Freya dark theme
   ---------------------------------------------------------------------------- */

.layout-wrapper.layout-topbar-dark .layout-topbar {
    background-color: #293241;
    box-shadow: 0 10px 40px 0 rgba(0, 0, 0, 0.2);
}

.layout-wrapper.layout-topbar-dark .user-profile-link:hover {
    background-color: rgba(255, 255, 255, 0.08);
}

.layout-wrapper.layout-topbar-dark .user-dropdown-menu {
    background: var(--surface-900, #1E1E1E);
    border-color: var(--surface-700, #383838);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 0 2px 6px rgba(0, 0, 0, 0.3);
}

.layout-wrapper.layout-topbar-dark .user-dropdown-divider {
    background-color: var(--surface-700, #383838);
}

.layout-wrapper.layout-topbar-dark .section-title {
    color: var(--text-color-secondary);
    opacity: 0.8;
}

.layout-wrapper.layout-topbar-dark .dropdown-item {
    color: var(--text-color);
}

.layout-wrapper.layout-topbar-dark .dropdown-item:hover {
    background-color: var(--surface-800, #2A2A2A);
}

.layout-wrapper.layout-topbar-dark .logout-item:hover {
    background-color: rgba(211, 47, 47, 0.1) !important;
}

/* ----------------------------------------------------------------------------
   RESPONSIVE DESIGN - Integration with Freya responsive patterns
   ---------------------------------------------------------------------------- */

@media (max-width: 991px) {
    .layout-topbar .user-dropdown-menu {
        left: 10px;
        right: 10px;
        position: fixed;
        top: 62px;
        max-width: none;
    }
}

@media (max-width: 768px) {
    .layout-topbar .user-dropdown-menu {
        min-width: 260px;
        max-width: 280px;
    }

    .user-dropdown-header {
        padding: 1rem 0.75rem;
    }

    .dropdown-item {
        padding: 0.625rem 0.75rem;
        font-size: 0.8125rem;
    }

    .section-title {
        padding: 0 0.75rem 0.5rem 0.75rem;
    }

    /* Hide user info on mobile */
    .layout-topbar .user-info {
        display: none;
    }

    .layout-topbar .user-profile-link {
        padding: 0.5rem;
    }
}

@media (max-width: 576px) {
    .layout-topbar .user-dropdown-menu {
        left: 8px;
        right: 8px;
        border-radius: 12px;
    }
}

/* ----------------------------------------------------------------------------
   ACCESSIBILITY ENHANCEMENTS
   ---------------------------------------------------------------------------- */

.dropdown-item:focus,
.user-profile-link:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    .layout-topbar .user-profile-link,
    .dropdown-item,
    .user-dropdown-menu,
    .user-avatar,
    .item-arrow {
        animation: none;
        transition: none;
    }
}

/* ----------------------------------------------------------------------------
   UTILITY CLASSES - PrimeFlex integration
   ---------------------------------------------------------------------------- */

.layout-topbar .flex {
    display: flex !important;
}

.layout-topbar .align-items-center {
    align-items: center !important;
}

.layout-topbar .justify-content-center {
    justify-content: center !important;
}

.layout-topbar .gap-2 {
    gap: 0.5rem !important;
}

.layout-topbar .text-white {
    color: white !important;
}

.layout-topbar .border-circle {
    border-radius: 50% !important;
}

.layout-topbar .bg-primary {
    background-color: var(--primary-color) !important;
}
