/* ============================================
   WIDGET DE USUARIO EN CABECERA
   ============================================ */

#user-widget-wrapper {
    position: fixed;
    top: 15px;
    right: 20px;
    z-index: 99999;
}

.user-widget {
    display: inline-flex;
    align-items: center;
    position: relative;
}

/* Ocultar elementos móviles en desktop */
.mobile-only {
    display: none;
}

/* ============================================
   USUARIO NO LOGUEADO
   ============================================ */

.user-widget.logged-out .btn-acceder {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, #037b84 0%, #35959c 100%);
    color: white;
    padding: 10px 20px;
    border-radius: 25px;
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.3s;
    box-shadow: 0 2px 10px rgba(3, 123, 132, 0.3);
}

.user-widget.logged-out .btn-acceder:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(3, 123, 132, 0.5);
}

.user-widget.logged-out .btn-icon {
    font-size: 18px;
}

/* ============================================
   USUARIO LOGUEADO - DESKTOP
   ============================================ */

.user-widget.logged-in {
    position: relative;
}

.user-profile-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 15px;
    border-radius: 25px;
    background: rgba(255, 255, 255, 0.95);
    text-decoration: none;
    transition: all 0.3s;
    cursor: pointer;
    border: 2px solid transparent;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.user-profile-link:hover {
    background: white;
    border-color: #037b84;
}

.user-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    overflow: hidden;
    border: 3px solid #037b84;
    padding: 5px;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.user-name {
    font-weight: 600;
    color: #333;
    font-size: 14px;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ============================================
   DROPDOWN DESKTOP
   ============================================ */

.user-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 10px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 5px 25px rgba(0,0,0,0.15);
    min-width: 200px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s;
    z-index: 1000;
}

.user-widget.logged-in:hover .user-dropdown.desktop-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: #333;
    text-decoration: none;
    transition: background 0.2s;
    font-size: 14px;
    border-bottom: 1px solid #f0f0f0;
}

.dropdown-item:first-child {
    border-radius: 10px 10px 0 0;
}

.dropdown-item:last-child {
    border-radius: 0 0 10px 10px;
    border-bottom: none;
}

.dropdown-item:hover {
    background: #f8f9fa;
}

.dropdown-item.logout {
    color: #d93b69;
}

.dropdown-item.logout:hover {
    background: #fef5f8;
}

.dropdown-icon {
    font-size: 18px;
}

.user-dropdown.desktop-dropdown::before {
    content: '';
    position: absolute;
    top: -8px;
    right: 20px;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 8px solid white;
}

/* ============================================
   PANEL MÓVIL DESLIZABLE
   ============================================ */

.mobile-user-panel {
    display: none;
}

/* Botón de apertura (<) - Solo en móvil */
.panel-toggle.open-panel {
    background: rgba(255, 255, 255, 0.95);
    border: 2px solid #037b84;
    border-radius: 8px 0 0 8px;
    width: 35px;
    height: 60px;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: -2px 0 10px rgba(0,0,0,0.1);
    transition: all 0.3s;
}

.panel-toggle span {
    font-size: 28px;
    font-weight: bold;
    color: #037b84;
    line-height: 1;
}

.panel-toggle:active {
    transform: scale(0.95);
}

/* ============================================
   RESPONSIVE - TABLET Y MÓVIL
   ============================================ */

@media (max-width: 768px) {
    #user-widget-wrapper {
        top: 10px;
        right: 0;
    }
    
    /* Ocultar elementos desktop */
    .desktop-only {
        display: none !important;
    }
    
    .desktop-dropdown {
        display: none !important;
    }
    
    /* Mostrar botón de apertura en móvil */
    .panel-toggle.open-panel {
        display: flex;
    }
    
    /* Panel móvil */
    .mobile-user-panel {
        display: flex;
        flex-direction: column;
        position: fixed;
        top: 0;
        right: -280px;
        height: 100vh;
        width: 280px;
        background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
        box-shadow: -5px 0 25px rgba(0,0,0,0.2);
        transition: right 0.3s ease-in-out;
        z-index: 99998;
        padding: 20px;
        overflow-y: auto;
    }
    
    /* Panel abierto */
    .mobile-user-panel.panel-open {
        right: 0;
    }
    
    /* Avatar en el panel */
    .panel-avatar {
        display: flex;
        flex-direction: column;
        align-items: center;
        padding: 20px 0;
        border-bottom: 2px solid #e0e0e0;
        margin-bottom: 20px;
    }
    
    .panel-avatar .user-avatar {
        width: 80px;
        height: 80px;
        margin-bottom: 15px;
    }
    
    .panel-username {
        font-weight: 700;
        font-size: 18px;
        color: #333;
        text-align: center;
    }
    
    /* Badge de rol del usuario */
    .user-role-badge {
        display: inline-block;
        margin-top: 12px; /* Separación con el username */
        padding: 8px 20px; /* Más padding interno */
        border-radius: 20px;
        font-size: 12px;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }
    
    /* Rol: Jugador (Verde/Turquesa) */
    .user-role-badge.role-jugador {
        background: rgba(248, 249, 250, 0.5) !important; /* Fondo semi-transparente que se adapta */
        color: #037b84;
        border: 2px solid transparent; /* Borde transparente para mantener el tamaño */
        box-shadow: 
            0 0 10px rgba(3, 123, 132, 0.5),
            0 0 20px rgba(3, 123, 132, 0.3),
            inset 0 0 10px rgba(3, 123, 132, 0.1);
        animation: neon-glow-green 2s ease-in-out infinite alternate;
    }
    
    @keyframes neon-glow-green {
        from {
            box-shadow: 
                0 0 10px rgba(3, 123, 132, 0.5),
                0 0 20px rgba(3, 123, 132, 0.3),
                inset 0 0 10px rgba(3, 123, 132, 0.1);
        }
        to {
            box-shadow: 
                0 0 20px rgba(3, 123, 132, 0.8),
                0 0 40px rgba(3, 123, 132, 0.5),
                inset 0 0 15px rgba(3, 123, 132, 0.2);
        }
    }
    
    /* Roles especiales: Líder, Administrador (Rosa) */
    .user-role-badge.role-lider,
    .user-role-badge.role-administrator,
    .user-role-badge.role-editor {
        background: rgba(248, 249, 250, 0.5) !important;
        color: #e17191;
        border: 2px solid transparent;
        box-shadow: 
            0 0 10px rgba(225, 113, 145, 0.5),
            0 0 20px rgba(225, 113, 145, 0.3),
            inset 0 0 10px rgba(225, 113, 145, 0.1);
        animation: neon-glow-pink 2s ease-in-out infinite alternate;
    }
    
    @keyframes neon-glow-pink {
        from {
            box-shadow: 
                0 0 10px rgba(225, 113, 145, 0.5),
                0 0 20px rgba(225, 113, 145, 0.3),
                inset 0 0 10px rgba(225, 113, 145, 0.1);
        }
        to {
            box-shadow: 
                0 0 20px rgba(225, 113, 145, 0.8),
                0 0 40px rgba(225, 113, 145, 0.5),
                inset 0 0 15px rgba(225, 113, 145, 0.2);
        }
    }
    
    /* Otros roles (Gris) */
    .user-role-badge.role-subscriber {
        background: rgba(248, 249, 250, 0.5);
        color: #666666;
        border: 2px solid transparent;
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
    }
    
    /* Acciones del panel */
    .panel-actions {
        display: flex;
        flex-direction: column;
        gap: 12px;
    }
    
    .mobile-action {
        display: flex;
        align-items: center;
        gap: 15px;
        padding: 15px 20px;
        background: white;
        border: 2px solid #e0e0e0;
        border-radius: 12px;
        text-decoration: none;
        color: #333;
        transition: all 0.3s;
        box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    }
    
    .mobile-action:active {
        transform: scale(0.98);
        border-color: #037b84;
        background: #f0f9ff;
    }
    
    .mobile-action.logout {
        border-color: #d93b69;
        color: #d93b69;
    }
    
    .mobile-action.logout:active {
        background: #fef5f8;
    }
    
    .action-icon {
        font-size: 24px;
        flex-shrink: 0;
    }
    
    .action-label {
        font-weight: 600;
        font-size: 15px;
    }
    
    /* Botón de cerrar dentro del panel */
    .close-panel-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 10px;
        padding: 15px 20px;
        background: linear-gradient(135deg, #d93b69, #e17191);
        border: none;
        border-radius: 12px;
        color: white;
        font-weight: 700;
        font-size: 15px;
        cursor: pointer;
        margin-top: 20px;
        box-shadow: 0 4px 12px rgba(217, 59, 105, 0.3);
        transition: all 0.3s;
    }
    
    .close-panel-btn:active {
        transform: scale(0.98);
        box-shadow: 0 2px 8px rgba(217, 59, 105, 0.4);
    }
    
    .close-panel-btn .btn-icon {
        font-size: 20px;
        font-weight: bold;
    }
    
    /* Usuario no logueado en móvil */
    .btn-text {
        display: none;
    }
    
    .user-widget.logged-out .btn-acceder {
        padding: 10px;
        border-radius: 50%;
        width: 45px;
        height: 45px;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .mobile-user-panel {
        width: 260px;
        right: -260px;
    }
    
    .panel-avatar .user-avatar {
        width: 70px;
        height: 70px;
    }
    
    .panel-username {
        font-size: 16px;
    }
    
    .mobile-action {
        padding: 12px 15px;
    }
    
    .action-label {
        font-size: 14px;
    }
    
    .close-panel-btn {
        padding: 12px 15px;
        font-size: 14px;
    }
}

