/* =======================================
   PROFILE HUB — Unified Navigation Menu
   One menu to rule them all.
   Triggered by clicking the user avatar.
   ======================================= */

/* --- Overlay Backdrop --- */
.profile-hub-overlay {
    position: fixed;
    inset: 0;
    background: var(--surface-overlay);
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

.profile-hub-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

/* --- Main Panel --- */
.profile-hub {
    position: fixed;
    top: 56px;
    right: 16px;
    width: 300px;
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 80px);
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.15),
        0 8px 24px rgba(0, 0, 0, 0.1);
    z-index: 10000;
    overflow: hidden;
    display: flex;
    flex-direction: column;

    /* Animation */
    opacity: 0;
    transform: translateY(-8px) scale(0.97);
    pointer-events: none;
    transition:
        opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1),
        transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.profile-hub.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* Deep Ether theme */
[data-theme="deep-ether"] .profile-hub {
    background: var(--glass-surface);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-color: var(--border-subtle);
    box-shadow:
        0 20px 60px rgba(4, 8, 30, 0.55),
        0 8px 24px rgba(4, 8, 30, 0.35),
        inset 0 1px 0 rgba(99, 140, 230, 0.05);
}

[data-theme="deep-ether"] .profile-hub-overlay {
    background: var(--modal-backdrop);
}

/* --- User Card Header --- */
.profile-hub-header {
    padding: 20px 16px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-surface-alt);
}

[data-theme="deep-ether"] .profile-hub-header {
    background: var(--surface-hover);
    border-color: var(--border-subtle);
}

.profile-hub-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border-color);
    flex-shrink: 0;
}

[data-theme="deep-ether"] .profile-hub-avatar {
    border-color: var(--border-subtle);
}

.profile-hub-user-info {
    flex: 1;
    min-width: 0;
}

.profile-hub-username {
    font-weight: 700;
    font-size: 15px;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.profile-hub-role {
    font-size: 11px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
}

.profile-hub-role-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.profile-hub-role-badge svg {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
}

.profile-hub-role-badge.role-admin {
    background: var(--role-admin-bg);
    color: var(--role-admin);
}

.profile-hub-role-badge.role-moderator {
    background: var(--role-mod-bg);
    color: var(--role-mod);
}

.profile-hub-role-badge.role-user {
    background: var(--role-user-bg);
    color: var(--role-user-color);
}

[data-theme="deep-ether"] .profile-hub-role-badge.role-admin {
    background: var(--role-admin-bg);
    color: var(--role-admin);
}

[data-theme="deep-ether"] .profile-hub-role-badge.role-moderator {
    background: var(--role-mod-bg);
    color: var(--role-mod);
}

[data-theme="deep-ether"] .profile-hub-role-badge.role-user {
    background: var(--role-user-bg);
    color: var(--role-user-color);
}

.profile-hub-status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: var(--text-muted);
}

.profile-hub-status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #22c55e;
    flex-shrink: 0;
}

/* --- Scrollable Content --- */
.profile-hub-body {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 6px 0;
}

/* --- Sections --- */
.profile-hub-section {
    padding: 4px 8px;
}

.profile-hub-section+.profile-hub-section {
    border-top: 1px solid var(--border-color);
    padding-top: 8px;
}

[data-theme="deep-ether"] .profile-hub-section+.profile-hub-section {
    border-color: var(--border-subtle);
}

.profile-hub-section-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    padding: 6px 10px 4px;
    opacity: 0.7;
}

/* --- Menu Items --- */
.profile-hub-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: 10px;
    color: var(--text-main);
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.1s ease;
    font-size: 13px;
    font-weight: 500;
    user-select: none;
    position: relative;
}

.profile-hub-item:hover {
    background: var(--bg-surface-alt);
}

.profile-hub-item:active {
    transform: scale(0.98);
}

[data-theme="deep-ether"] .profile-hub-item:hover {
    background: var(--surface-hover);
}

/* Item icon */
.profile-hub-item-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-size: 14px;
    flex-shrink: 0;
    transition: transform 0.15s ease;
}

/* Lucide SVG icons in profile hub */
.profile-hub-item-icon svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.profile-hub-theme-btn svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.profile-hub-item:hover .profile-hub-item-icon {
    transform: scale(1.08);
}

/* Icon color variants */
.ph-icon-blue {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
}

.ph-icon-green {
    background: rgba(34, 197, 94, 0.1);
    color: #22c55e;
}

.ph-icon-indigo {
    background: rgba(99, 102, 241, 0.1);
    color: #6366f1;
}

.ph-icon-cyan {
    background: rgba(6, 182, 212, 0.1);
    color: #06b6d4;
}

.ph-icon-purple {
    background: rgba(168, 85, 247, 0.1);
    color: #a855f7;
}

.ph-icon-amber {
    background: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
}

.ph-icon-orange {
    background: rgba(249, 115, 22, 0.1);
    color: #f97316;
}

.ph-icon-red {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.ph-icon-teal {
    background: rgba(20, 184, 166, 0.1);
    color: #14b8a6;
}

.ph-icon-slate {
    background: rgba(100, 116, 139, 0.1);
    color: #64748b;
}

.ph-icon-gold {
    background: rgba(234, 179, 8, 0.1);
    color: #eab308;
}

/* Deep ether: slightly brighter backgrounds */
[data-theme="deep-ether"] .ph-icon-blue {
    background: rgba(59, 130, 246, 0.15);
}

[data-theme="deep-ether"] .ph-icon-green {
    background: rgba(34, 197, 94, 0.15);
}

[data-theme="deep-ether"] .ph-icon-indigo {
    background: rgba(99, 102, 241, 0.15);
}

[data-theme="deep-ether"] .ph-icon-cyan {
    background: rgba(6, 182, 212, 0.15);
}

[data-theme="deep-ether"] .ph-icon-purple {
    background: rgba(168, 85, 247, 0.15);
}

[data-theme="deep-ether"] .ph-icon-amber {
    background: rgba(245, 158, 11, 0.15);
}

[data-theme="deep-ether"] .ph-icon-orange {
    background: rgba(249, 115, 22, 0.15);
}

[data-theme="deep-ether"] .ph-icon-red {
    background: rgba(239, 68, 68, 0.15);
}

[data-theme="deep-ether"] .ph-icon-teal {
    background: rgba(20, 184, 166, 0.15);
}

[data-theme="deep-ether"] .ph-icon-slate {
    background: rgba(100, 116, 139, 0.15);
}

[data-theme="deep-ether"] .ph-icon-gold {
    background: rgba(234, 179, 8, 0.15);
}

/* Item text area */
.profile-hub-item-text {
    flex: 1;
    min-width: 0;
}

/* Item badge (e.g. unread count) */
.profile-hub-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
    background: var(--accent-danger, #ef4444);
    color: white;
    flex-shrink: 0;
}

.profile-hub-badge.blue {
    background: #3b82f6;
}

.profile-hub-badge:empty,
.profile-hub-badge[data-count="0"] {
    display: none;
}

/* Toggle switch inline */
.profile-hub-item .toggle-switch {
    margin-left: auto;
    pointer-events: none;
}

/* Item with inline value (like "Bloqués: Discret") */
.profile-hub-item-value {
    margin-left: auto;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
}

/* --- Theme Switcher Row --- */
.profile-hub-theme-row {
    display: flex;
    gap: 4px;
    padding: 4px 10px;
    margin: 2px 8px 4px;
    background: var(--bg-surface-alt);
    border-radius: 10px;
}

[data-theme="deep-ether"] .profile-hub-theme-row {
    background: rgba(99, 140, 230, 0.04);
}

.profile-hub-theme-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 7px 0;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.profile-hub-theme-btn:hover {
    background: var(--bg-surface);
    color: var(--text-main);
}

.profile-hub-theme-btn.active {
    background: var(--accent-primary);
    color: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

[data-theme="deep-ether"] .profile-hub-theme-btn:hover {
    background: var(--surface-hover);
}

[data-theme="deep-ether"] .profile-hub-theme-btn.active {
    background: var(--primary-azure, #3b82f6);
}

/* Grey theme overrides for profile hub */
[data-theme="grey"] .profile-hub {
    background: var(--glass-surface);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-color: var(--border-subtle);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.25);
}

[data-theme="grey"] .profile-hub-overlay {
    background: var(--modal-backdrop);
}

[data-theme="grey"] .profile-hub-header {
    background: var(--surface-hover);
    border-color: var(--border-subtitle);
}

[data-theme="grey"] .profile-hub-theme-row {
    background: rgba(99, 140, 230, 0.04);
}

[data-theme="grey"] .profile-hub-theme-btn:hover {
    background: var(--surface-hover);
}

[data-theme="grey"] .profile-hub-theme-btn.active {
    background: var(--accent-primary);
}

[data-theme="grey"] .profile-hub-item:hover {
    background: var(--surface-hover);
}

[data-theme="grey"] .profile-hub-section+.profile-hub-section {
    border-color: var(--border-subtle);
}

[data-theme="grey"] .profile-hub-footer {
    border-color: var(--border-subtle);
}

/* Custom theme overrides for profile hub */
[data-theme="custom"] .profile-hub {
    background: var(--glass-surface);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-color: var(--border-subtle);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.25);
}

[data-theme="custom"] .profile-hub-overlay {
    background: var(--modal-backdrop);
}

[data-theme="custom"] .profile-hub-header {
    background: var(--surface-hover);
    border-color: var(--border-subtle);
}

[data-theme="custom"] .profile-hub-theme-row {
    background: rgba(99, 140, 230, 0.04);
}

[data-theme="custom"] .profile-hub-theme-btn:hover {
    background: var(--surface-hover);
}

[data-theme="custom"] .profile-hub-theme-btn.active {
    background: var(--accent-primary);
}

[data-theme="custom"] .profile-hub-item:hover {
    background: var(--surface-hover);
}

[data-theme="custom"] .profile-hub-section+.profile-hub-section {
    border-color: var(--border-subtle);
}

[data-theme="custom"] .profile-hub-footer {
    border-color: var(--border-subtle);
}

/* --- Custom Hue Picker --- */
.custom-hue-picker {
    margin: 8px 10px 4px;
    padding: 10px 12px;
    background: var(--bg-surface-alt);
    border-radius: 10px;
    transition: all 0.25s ease;
}

.custom-hue-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.custom-hue-swatch {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.15);
    transition: background 0.1s ease;
    box-shadow: 0 0 8px rgba(0, 0, 0, 0.2);
}

/* Rainbow range slider */
.custom-hue-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 10px;
    border-radius: 5px;
    outline: none;
    cursor: pointer;
    background: linear-gradient(to right,
            hsl(0, 85%, 55%),
            hsl(30, 85%, 55%),
            hsl(60, 85%, 55%),
            hsl(90, 85%, 55%),
            hsl(120, 85%, 55%),
            hsl(150, 85%, 55%),
            hsl(180, 85%, 55%),
            hsl(210, 85%, 55%),
            hsl(240, 85%, 55%),
            hsl(270, 85%, 55%),
            hsl(300, 85%, 55%),
            hsl(330, 85%, 55%),
            hsl(360, 85%, 55%));
}

.custom-hue-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: white;
    border: 2px solid rgba(0, 0, 0, 0.2);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    cursor: grab;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.custom-hue-slider::-webkit-slider-thumb:hover {
    transform: scale(1.15);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.4);
}

.custom-hue-slider::-webkit-slider-thumb:active {
    cursor: grabbing;
    transform: scale(1.1);
}

.custom-hue-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: white;
    border: 2px solid rgba(0, 0, 0, 0.2);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    cursor: grab;
}

.custom-hue-slider::-moz-range-thumb:hover {
    transform: scale(1.15);
}

.custom-hue-slider::-moz-range-track {
    height: 10px;
    border-radius: 5px;
    background: transparent;
    border: none;
}

/* --- Danger Item (Logout) --- */
.profile-hub-item-danger {
    color: var(--accent-danger, #ef4444);
}

.profile-hub-item-danger .profile-hub-item-icon {
    background: rgba(239, 68, 68, 0.08);
    color: var(--accent-danger, #ef4444);
}

.profile-hub-item-danger:hover {
    background: rgba(239, 68, 68, 0.06);
}

[data-theme="deep-ether"] .profile-hub-item-danger:hover {
    background: rgba(239, 68, 68, 0.1);
}

/* --- Footer --- */
.profile-hub-footer {
    border-top: 1px solid var(--border-color);
    padding: 4px 8px;
}

[data-theme="deep-ether"] .profile-hub-footer {
    border-color: var(--border-subtle);
}

/* =======================================
   MOBILE RESPONSIVE — Profile Hub
   On mobile: bottom sheet style
   ======================================= */
@media (max-width: 768px) {
    .profile-hub {
        top: 0;
        bottom: 0;
        left: 0;
        right: auto;
        width: 75vw;
        max-width: 320px;
        max-height: 100vh;
        border-radius: 0 20px 20px 0;
        transform: translateX(-100%);
        border: none;
        /* simpler look on edge */
        border-right: 1px solid var(--border-color);
    }

    .profile-hub.open {
        transform: translateX(0);
    }

    /* Remove top drag handle since it's a side drawer now */
    .profile-hub::before {
        display: none;
    }

    .profile-hub-header {
        padding-top: calc(env(safe-area-inset-top, 0px) + 20px);
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .profile-hub-avatar {
        width: 56px;
        height: 56px;
    }

    /* Larger touch targets on mobile */
    .profile-hub-item {
        padding: 12px 12px;
        font-size: 14px;
    }

    .profile-hub-item-icon {
        width: 36px;
        height: 36px;
        font-size: 15px;
    }

    .profile-hub-theme-btn {
        padding: 10px 0;
        font-size: 13px;
    }

    /* Safe area */
    .profile-hub-footer {
        padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    }
}

/* =======================================
   HEADER LOGO — Now always links home
   ======================================= */
.header-logo-link-home {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: var(--text-main);
    transition: opacity 0.2s ease;
}

.header-logo-link-home:hover {
    opacity: 0.85;
}

/* Header avatar trigger for profile hub */
.header-profile-trigger {
    position: relative;
    cursor: pointer;
}

.header-profile-trigger .header-avatar {
    transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.header-profile-trigger.active .header-avatar {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(168, 197, 69, 0.2);
}

[data-theme="deep-ether"] .header-profile-trigger.active .header-avatar {
    border-color: var(--primary-azure, #3b82f6);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

/* =======================================
   SIDEBAR FOOTER — Simplified
   Just avatar + name + home button
   No more duplicated dropdown
   ======================================= */
.sidebar-footer-simple {
    padding: 12px 15px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-surface);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-footer-simple .sidebar-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    cursor: pointer;
}

.sidebar-footer-simple .sidebar-user-name {
    font-weight: 600;
    font-size: 13px;
    color: var(--text-main);
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-footer-simple .sidebar-home-link {
    color: var(--text-muted);
    font-size: 16px;
    padding: 6px;
    border-radius: 6px;
    transition: color 0.2s, background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-footer-simple .sidebar-home-link:hover {
    color: var(--accent-primary);
    background: var(--bg-surface-alt);
}

.sidebar-footer-simple .sidebar-auth-buttons {
    display: flex;
    gap: 8px;
    width: 100%;
}

[data-theme="deep-ether"] .sidebar-footer-simple {
    background: var(--surface-overlay);
    border-color: var(--border-subtle);
}

.sidebar-footer-simple .sidebar-user-avatar:hover {
    border-color: var(--accent-primary);
    transform: scale(1.05);
    transition: transform 0.2s ease, border-color 0.2s ease;
}

/* =======================================
   SCROLLBAR for Profile Hub
   ======================================= */
.profile-hub-body::-webkit-scrollbar {
    width: 4px;
}

.profile-hub-body::-webkit-scrollbar-track {
    background: transparent;
}

.profile-hub-body::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 2px;
}

[data-theme="deep-ether"] .profile-hub-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
}